Everytime I press Z to interact with the menu, it doesn't respond?
You should check the variable in debug mode because it might not be 1 or 2. Also we can't see the events for opening the menu so maybe that's where it goes wrong for closing it.
Develop games in your browser. Powerful, performant & highly capable.
Figured it out!