CanTeleport = script.Parent.Value.Value
CanTeleport = true
script.Parent.Touched:connect(function(hit)
if CanTeleport == true then
CanTeleport = false
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
hit.Parent.Head.CFrame = CFrame.new(114, -34.1, -368)
CanTeleport = true
wait(1)
end
end
end)
The script above was not working, after the second time of using it. It worked the first time fine, but then after the second time it said "Head is not a Part of Accessory" or something like that.
After adding wait(0.2) to line 6 it worked, but what I just don't understand is why. Why do I need to allow the computer to wait for 0.2 seconds in order for it to function properly? As you probably know I'm new to scripting so please try to be.. simplistic with answering.

3 comments
You shouldn't have to wait. Can you reproduce the exact error? I tested this script in studio, without a wait, but couldn't reproduce the error.
Works fine for me as well. The error seems to convey that there's a Humanoid in your Hat's (Accessory), which is the only way I could reproduce that error.
Yeah, it looks like it's just coincidental and you're hitting the wrong part of the brick.. if i'm reading it right (i'm tired.)