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
10 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.

function onClick()
game.Players.LocalPlayer.PlayerGui.ScreenGui:Destroy()
end

LocalScript.Parent.MouseButton1Click:connect(onClick)

2 answers

Log in to vote
2
Answered by
Vathriel 510 Moderation Voter
10 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 — 10y
Ad
Log in to vote
1
Answered by 10 years ago
function onClick()
script.Parent:remove()
end
script.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