Can't Click Button with Cursor in FPS

I am pretty new to unity–

I am trying to have a quest pop up, and click the accept or decline button. Everything functions the way it should, except I cannot get my cursor to show up during the quest prompt and disappear after hitting accept or decline.

I’ve tried coding so many different ways with locking the cursor and making the cursor visible/invisible, but nothing seems to stick.

At the moment I have the FPSController ticked option “lock and hide cursor”, with the code

    void Update() {
        TheDistance = PlayerCasting.DistancefromTarget;
        
    }

void OnMouseOver(){ 
    if (TheDistance <= 3) {
        ActionDisplay.SetActive(true);
        ActionText.SetActive(true);
       Cursor.lockState = CursorLockMode.None;
        }

        if (Input.GetButtonDown("Action") && TheDistance <= 3)
        {
            ActionDisplay.SetActive(false);
            ActionText.SetActive(false);
            UIQuest.SetActive(true);
            NoticeCam.SetActive(true);
            ThePlayer.SetActive(false);

        }
    }

void OnMouseExit() {
      
    ActionDisplay.SetActive (false);
    ActionText.SetActive (false);
   Cursor.lockState = CursorLockMode.Locked;
}


}

I had encountered a similar problem, but thanks to @DenisIsDenis …i got it sorted…it appears that you have to first set the cursor visible to make it appear…i will share the simple code Denis gave me

 void ShowCursor ()
 {
     if (! Cursor.visible || Cursor.lockState == CursorLockMode.Locked)
     {
         Cursor.visible = true;
         Cursor.lockState = CursorLockMode.None;
     }
 }

just call ShowCursor whenever you want to make the cursor visible…and it should work for you