Input Priority

I’m programming a little game for Android where the player jumps as soon as I press the button (from the project using the mouse button) and I also have a UI button on the screen which would be the pause button, the problem is that when I press the pause button the player jumps and then the pause occurs, and i don’t want that the player jump first , is there a priority management of events? Is there a way to avoid checking if the inputs are squashed in certain areas of the screen? How would you handle this problem?
Thank you!

Please, post your code for both the button and your player, using code tags. Thank you.

The Button is a classic UI Button where in the ispector you have the On Click() that you need to add the script and the function associated , in this case GameManager.cs → TogglePause()

GameManager script

private void DisableEnableAll()
{
    //Unity non selezionava gli oggetti inattivi , con questo metodo invece si
    GameObject[] y = Resources.FindObjectsOfTypeAll<GameObject>();
    foreach (GameObject element in y)
    {
        if (element.transform.parent != null) continue;
        if (element.name == "Main Camera") continue;
        if (element.name == "Pause") continue;
        if (element.name == "GameManager") continue;
        if (element.name == "EventSystem") continue;
        element.SetActive(!inPause);
    }

}
public void TogglePause()
{
    inPause = !inPause;
    DisableEnableAll();
    pauseButton.SetActive(!inPause); pauseMenu.SetActive(inPause);
}

PlayerControllerScript:

void Update()
{
    this.transform.position = new Vector3(this.transform.position.x + Speed * Time.deltaTime, this.transform.position.y, this.transform.position.z);
    if (Input.GetMouseButtonDown(0)&&Ground)
    {
        rb.AddForce(new Vector3(0, JumpForce, 0),ForceMode.Impulse);
        Ground = false;
    }
}