local Detector = script.Parent.ClickDetector
local Tool = game.Workspace["Green Key"]
local Part = script.Parent
Detector.MouseClick:Connect(function(Player)
game.Workspace.BoogieBattle.boogiedispenser.sign.Part.SurfaceGui.TextLabel.Visible = true
if game.Players.LocalPlayer.PlayerGui.Values.NC.NCValue.Value == 10 then
local Clone = Tool:Clone()
local handle = Clone:FindForChild("Handle")
Clone.CFrame = game.Workspace.tppart.CFrame
Part:Destroy()
else
game.Workspace.BoogieBattle.boogiedispenser.sign.Part.SurfaceGui.TextLabel.Text = "You dont have enough NoseCoins!"
wait(3)
game.Workspace.BoogieBattle.boogiedispenser.sign.Part.SurfaceGui.TextLabel.Text = "You must pay 10 Nose Coins to play Boogie Battle"
end
end)
This script above is a script that needs to find PlayerGui, so it can either post a message and dispense a key, or show a different message.
I have many scripts with this error, and this error: "Attempt to index nil as "PlayerGui" keeps destroying my sanity to get my games finished.

2 comments
Use :WaitForChild("PlayerGui") when you refer to playergui
just appears with attempt to index nil with wait for child