Hello my name is chill22518, I have created a script that is placed under a part. I have called this part 'Anvil'. When a player touches the part, a screen GUI is supposed to pop up. Although this has worked in Studio mode, it does not seem to work as efficiently in a normal game. I have also tried using a local script instead of a normal script, but it still seems to not comply.
Anvil = game.Workspace.Anvil
local function Click(player)
if player.Parent.Humanoid then
Player = game.Players.LocalPlayer
PlayerGui = Player:WaitForChild("PlayerGui")
Gui = PlayerGui:WaitForChild("CraftGui")
Gui.Enabled = true
end
end
Anvil.Touched:connect(Click)
I would appreciate it if you could help me figure out this problem as I have been striving to solve it for a long time.
Kind regards. chill22518

1 comment
this will error is an NPC or a model with a child called Humanoid touches the anvil as player would be nil.