Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I make a gui pop up and close?

Asked by 11 years ago

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?

2 answers

Log in to vote
1
Answered by
Sublimus 992 Moderation Voter
11 years ago

Have a variable whose value is equal to whether or not it is closed:

01open = false
02gui = script.Parent.Parent.Gui -- Change the location to the location of the Gui Frame you are trying to open/close
03script.Parent.MouseButton1Down: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
13end)
Ad
Log in to vote
-1
Answered by 11 years ago

Like this, I hope. Put this inside the button

01local gui = script.Parent
02local on = false
03gui.Visible = false
04gui.Active = false
05gui.MouseButton1Down: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
16end)

This was done in a rush, hope it works. :)

Answer this question