While a menu is open. witch is the better way to don't allow other scrips get key codes?

The problem is that when i close the menu with left click, the wepon equiped shoots.

pd: With “key codes” I mean keyUp(), KeyDown() …

Set a bool variable to true when the menu is open and in the input’s if statements add if((Input) && !menuBool){ to check the menu isn’t open. When the menu is closed start a coroutine and have the bool wait a frame or millisecond before setting it to false.

It’s best to have a controller script that controls which inputs are allowed or not. Commonly the Game-State pattern is used for this.

	States:

	- Default
	- InGame
	- InMenu
	- Paused

	enum GameState  {
		Default,
		InGame,
		InMenu,
		Paused
	}

	// Game state variable 
	public GameState gameState = GameState.Default;

	public GameObject UI;
	public GameObject Game;

	void Update () {
		switch (gameState){
			case (GameState.Default):
				UI.GetComponent<UIController>().Show();
				Game.GetComponent<GameController>().Reset();
				return;
			case (GameState.InGame):
				UI.GetComponent<UIController>().Hide();
				Game.GetComponent<GameController>().Play();
				return;
			case (GameState.InMenu):
				UI.GetComponent<UIController>().Show();
				Game.GetComponent<GameController>().Pause();
				return;
			case (GameState.Paused):
				UI.GetComponent<UIController>().Hide();
				Game.GetComponent<GameController>().Pause();
				return;
		}
	}

	if (GameState == GameState.InGame){
		
	}