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

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

Asked by
ghxstlvty 133
4 years ago

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..?

0
paste this into the gui script HenriqueHome31 22 — 4y
0
if this doesn't work add more Parent or remove it HenriqueHome31 22 — 4y
0
.Visible = not? KDarren12 705 — 4y
0
yeh HenriqueHome31 22 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
script.Parent.MouseButton1Click:connect(function()

    script.Parent.Parent.Parent.NAME.Visible =  not script.Parent.Parent.Parent.NAME.Visible
end)
0
Visible should be "false", not "not". KDarren12 705 — 4y
0
if you're trying to make it false KDarren12 705 — 4y
0
use variables theking48989987 2147 — 4y
0
ye HenriqueHome31 22 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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.

Answer this question