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

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

Asked by 9 years ago

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

Log in to vote
1
Answered by 9 years ago

The script is fine, it just needs to be a localscript in the gui button and filtering enabled needs to be off.

Ad
Log in to vote
5
Answered by 9 years ago

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!

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 XxDarkMiragexX 45 — 9y
0
oh, as long as your problem is fixed BSIncorporated 640 — 9y
Log in to vote
-2
Answered by 9 years ago

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

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. M39a9am3R 3210 — 9y

Answer this question