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

GUI Close Button Not Working, Use to work before? [RESOLVED]

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)

3 answers

✓ Accepted answer

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!

2 comments

0

Thanks, but the issue was that FilteringEnabled was on. Plus, I need the GUI to be remved, because it is copied into the player's GUI and would appear again if he/she touched the brick

0

oh, as long as your problem is fixed

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

1 comment

0
  1. You're on the right track, remove is deprecated. 2. Both events you mentioned are compatible to work. It's MouseClick for click detectors I beleive.

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