local part = script.Parent local player = game.Players.LocalPlayer if player.PlayerGui:FindFirstChild(“NPCmessage”) then part:FindFirstChild(“ClickDetector”):Destroy() else local ClickDetector = Instance.new(“ClickDetector”) ClickDetector.Parent = part ClickDetector.MouseClick:Connect(function() local GUI = script.NPCmessage:Clone GUI.Parent = Player.PlayerGui end) end
in line 2 it was player then in line 12 it became Player with a capital
so just change Player to player in line 12
First of all, you made a spelling mistake with Clone()
. After that, you accidentally set player
to Player
. Also PlayerGui
may not have loaded yet so use WaitForChild to be on the safe side. Be a little careful next time!
local part = script.Parent local player = game.Players.LocalPlayer -- Variable for player local PlayerGui = player:WaitForChild("PlayerGui") if PlayerGui:FindFirstChild(“NPCmessage”) then part:FindFirstChild(“ClickDetector”):Destroy() else local ClickDetector = Instance.new(“ClickDetector”) ClickDetector.Parent = part ClickDetector.MouseClick:Connect(function() local GUI = script.NPCmessage:Clone() GUI.Parent = PlayerGui -- Set's the GUI end) end