Have Only Button Respond To Left Click?

I have some scripts that always check for clicks from the mouse. If I left click to attack it attacks with no problem. When I open a simple pause menu I created and left click on a button it activates the Input for attack. Is there a way to simply fix this without having to add some things to each Input If statement?

You can do this with bools. When you have any UI open you should set a bool to true and when its closed set it to false. If you make this static you can check it from anywhere without having to have a specific reference to the UI script

in your UI script:

private static YourUIScriptName _yourscript;
public bool uiOpen = false;

void Start(){
_yourscript = this;
}
public static bool UICheck(){
return _yourscript.uiOpen;
}

//use "YourUIScriptName.SetUI(true)" from any script to set whether the ui is on or not
public static void SetUI(bool isOn){
_yourscript.uiOpen = isOn;
}

And the script where you are checking for the attack input:

if(Input.GetKeyDown(yourattackbutton) && !YourUIScriptName.UICheck()){
//attack
}

@LoneWolf31322 One easy way is to simply disable the scripts that check for the mouse click.

I assume your pause menu triggers when you press a key.

if(pause == true) // the if statement you use to trigger the pause
{
        GetComponent<AttackScript>().enabled = false; // disable click scripts
//same for other scripts
}
else
{
        GetComponent<AttackScript>().enabled = true; //re-enable click scripts
//same for other scripts
}

Or
,If your scripts are on too many different objects, then an even simpler way is to set the timeScale. I personally prefer this way because it prevents all other objects from moving as well, i.e. AI controllers, physics, animations, particle effects, etc.

if(paused == true) // When the game is paused
{
        Time.timeScale = 0; //The timescale is zero, nothing moves, time doesn't pass ingame
}
else
{
        Time.timeScale = 1.0; // time resumes normally
}

this way is great for single player games, but can really mess things up in multiplayer. The choice is entirely up to you.