Another GUI question. enable and disable

Hi All I was looking around for a script to make a gui menu appear and dissapear and found lots with a key press but I was wondering if it was possible to make it so you can enable and disable a gui menu with a gui button?

Like a button that when you press it shows the GUI menu and then when it is open and you press the button again then it will close the menu again?

I have the menu all done with ongui but I have no idea how to make the button ? Please help me

Just add a boolean variable to keep track of the menu state, i.e., isMenuOpen.

When the button that opens/closes it is clicked, toggle this variable’s value (isMenuOpen=!isMenuOpen).

Then wrap the code that draws the menu in an conditional, if(isMenuOpen) { draw the menu }

If you also want the menu to close when a button inside the menu is clicked, you can just add “isMenuOpen=false” to that button’s code.

Hope this helps!