I had a close button for my GUI and it worked before. I guess Roblox broke it, but oddly enough it works in Studio Testing (F5) but not in Server Testing (F7 or joining the actual game)
function close() script.Parent.Parent:Remove() end script.Parent.MouseButton1Click:connect(close)
The script is fine, it just needs to be a localscript in the gui button and filtering enabled needs to be off.
EDIT #2
Your script should work as long as the
script.Parent.Parent:Remove()
is in the correct form.
I would recommend using the visibility setting in your frame or button
in that case your script would be
function close() script.Parent.Parent.Visible = false end script.Parent.MouseButton1Click:connect(close)
You can also make a button that opens and closes what you choose using if
and else
function click() if script.Parent.Parent.Visible == true then script.Parent.Parent.Visible = false else script.Parent.Parent.Visible = true end end script.Parent.MouseButton1Click:connect(click)
Please accept answer if this helped.
Let me know if there are any bugs that I need to fix first.
THANKS!
I believe two things are wrong: 1. Destroy, not remove is the term for deleting. 2. It's MouseButton1Down, MouseButton1Click is for ClickDetectors. Please tell me if this helped :)