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

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

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?

2 comments

0

The question is quite broad. Post more information. Script type? Location?

0

Ok, The script is a normal script, and It's in a textbutton in a startergui.

1 answer

✓ Accepted answer

###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)

1 comment

0

Thank you :D

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