I have a script that teleports a player once they step on it. The problem is that once they step on it once they get stuck in an infinite loop as it keeps on teleporting them back and for. I need to create a wait time so that it only inputs the code every 10 seconds or so. I've been trying to figure out how to do this with debounce but I am new to scripting and I am quite confused.
local Teleport = "Teleporter"
function Touch(hit)
wait (5)
if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true
local Pos = script.Parent.Parent:findFirstChild(Teleport).
hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end
script.Parent.Touched:connect(Touch)

2 comments
Do you mean so you cant spam the script over and over again?
Yes that is what I mean. Once I teleport up to the top teleporter it starts the script again and just teleports me back down