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

How do I make a working close GUI button..? Mine does not work properly!

I correctly have a script that when you click the X button on the GUI it closes the GUI, no problem there. I go to open the GUI again... It doesn't appear. Does anyone know the problem..?

4 comments

0

paste this into the gui script

0

if this doesn't work add more Parent or remove it

0

.Visible = not?

0

yeh

2 answers

✓ Accepted answer
script.Parent.MouseButton1Click:connect(function()
	
	script.Parent.Parent.Parent.NAME.Visible = 	not script.Parent.Parent.Parent.NAME.Visible
end)

4 comments

0

Visible should be "false", not "not".

0

if you're trying to make it false

0

use variables

0

ye

Don't use Instance:Destroy() in this case, instead use Instance.Visible or Enabled if the Instance is a ScreenGui.

Example:

local UI = script.Parent.Parent
script.Parent.MouseButton1Click:Connect(function()
	UI.Visible = false
end)

If you're trying to make it so you can use the same button to open/close it, use a debounce

Example:

local UI = script.Parent.Parent
local debounce = false
script.Parent.MouseButton1Click:Connect(function()
	if debounce then
		UI.Visible = true
		debounce = false
	else
		UI.Visible = false
		debounce = true
	end
end)

I cannot guarantee these exact scripts will work for you because you did not provide any code or any tree of your Gui. For further notice, please show your current code and what you're working with or it seems more like a request.

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