Script wait function not working

local Touched = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) and not touched then
touched = true
wait(2) – add a two-second delay
hit.Parent.HumanoidRootPart.CFrame = CFrame.new(46, 38.25, -110.669)
touched = false
end
end)

The player has to stay in the part for two seconds to be teleported. If the player leaves the part the timer is useless.

The wait wont work how its supposed to be, since its just delaying the Teleport function.after the wait, i would recomend you to add another if hit.parent function, that should fix the problem, although that is not the best way to do it

Basically as the code is set right now, the game is waiting 2 seconds before teleporting you, even if you left the part/block

local Touched = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) and not touched then
touched = true
wait(2) – add a two-second delay
if hit.Parent:FindFirstChild(“Humanoid”) and touched then
hit.Parent.HumanoidRootPart.CFrame = CFrame.new(46, 38.25, -110.669)
touched = false
end
end
end)