I'm using a textbutton. I know how I would make a shop gui open, but how would I make it close when you press it again, and open after that?
Have a variable whose value is equal to whether or not it is closed:
01 | open = false |
02 | gui = script.Parent.Parent.Gui -- Change the location to the location of the Gui Frame you are trying to open/close |
03 | script.Parent.MouseButton 1 Down:connect( function () |
04 | if open = = false then |
05 | gui.Visible = true |
06 | script.Parent.Text = "Close" |
07 | open = true |
08 | else |
09 | gui.Visible = false |
10 | script.Parent.Text = "Open" |
11 | open = false |
12 | end |
13 | end ) |
Like this, I hope. Put this inside the button
01 | local gui = script.Parent |
02 | local on = false |
03 | gui.Visible = false |
04 | gui.Active = false |
05 | gui.MouseButton 1 Down:connect( function () |
06 | if on = = false then |
07 | gui.Visible = true |
08 | gui.Active = true |
09 | on = true |
10 | end |
11 | if on = = true then |
12 | gui.Visible = false |
13 | gui.Active = false |
14 | on = false |
15 | end |
16 | end ) |
This was done in a rush, hope it works. :)