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

How do I destroy a PlayerGui by using MouseButton1Click?

Asked by
NecoBoss 194
11 years ago

Okay I am experimenting with GUI's and I'm trying to hide or destroy a GUI button when clicked. I've made this code but it doesn't work.

1function onClick()
2game.Players.LocalPlayer.PlayerGui.ScreenGui:Destroy()
3end
4 
5LocalScript.Parent.MouseButton1Click:connect(onClick)

2 answers

Log in to vote
2
Answered by
Vathriel 510 Moderation Voter
11 years ago

That's because it's not "LocalScript" even if it is in a local script, It's still just "script"

0
Thanks. NecoBoss 194 — 11y
Ad
Log in to vote
1
Answered by 11 years ago
1function onClick()
2script.Parent:remove()
3end
4script.Parent.MouseButton1Click:connect(onClick)

It is not a Even if it is a local script you still use script. Also, try using regular scripts.

Answer this question