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
COMMUNITY QUESTION
Why won't this script work? (I need assistance ASAP)
2 answers
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
3 comments
0
also in line 11 try Clone()
0
Thanks guys!!! Really appreciate it!
0
@Sewnpai If the answer solves your issue, mark it as accepted
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
1 comment
0
What's with the “ rather than " or '
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
try using :Clone() instead of :Clone