Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I make a gui pop up and close?

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

✓ Accepted answer

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)

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. :)

This discussion is preserved as it was. New answers, comments, and votes are closed.