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

Hello, I am needing help with this Open/Close button for my GUI. Can you help?

Asked by 5 years ago

Hello, I am needing help with this Open/Close button for my GUI. This is my current script:

script.Parent.MouseButton1Click:connect(function()
if script.Parent.Parent.Frame.Visible == false then
script.Parent.Parent.Frame.Visible = true
script.Parent.Text = "Close"
if script.Parent.Parent.Frame.Visible == true then
    script.Parent.Parent.Frame.Visible = false
    script.Parent.Text = "Open"
end
end
end)

It isn't working when I go in test mode and click on it.

Can you help me?

0
The question is quite broad. Post more information. Script type? Location? User#19524 175 — 5y
0
Ok, The script is a normal script, and It's in a textbutton in a startergui. Starnamics 24 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Your script did not work because it was a Script. Before Experimental Mode was completely removed, Scripts were able to run in PlayerGui. But since Experimental Mode was removed, this is no longer the case. FilteringEnabled has been forced, but FE compatibility is not required for your script. The change really is to make it a LocalScript. It can also be made much shorter and cleaner.

local frame = script.Parent.Parent.Frame

script.Parent.MouseButton1Click:Connect(function() -- connect is deprecated use Connect
   frame.Visible = not frame.Visible -- easy way to toggle a boolean 

    script.Parent.Text = frame.Visible and "Close" or "Open"
    -- here, if the frame is not visible, the text will show "Open". If it is visible, show "Close"
end)

0
Thank you :D Starnamics 24 — 5y
Ad

Answer this question