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 10 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
10 years ago

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

open = false
gui = script.Parent.Parent.Gui -- Change the location to the location of the Gui Frame you are trying to open/close
script.Parent.MouseButton1Down:connect(function()
    if open == false then
        gui.Visible = true
        script.Parent.Text = "Close"
        open = true
    else
        gui.Visible = false
        script.Parent.Text = "Open"
        open = false
    end
end)
Ad
Log in to vote
-1
Answered by 10 years ago

Like this, I hope. Put this inside the button

local gui = script.Parent
local on = false
gui.Visible = false
gui.Active = false
gui.MouseButton1Down:connect(function()
    if on == false then     
        gui.Visible = true
        gui.Active = true
        on = true
    end
    if on == true then      
        gui.Visible = false
        gui.Active = false
        on = false
    end
end)

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

Answer this question