Hello, I am new to scripting and would like to know how to make teleport pads only teleport once. So if you stand on a teleport pad,you won't teleport back and forth.
local Teleport = "Lentilkac58-Easy-Teleport-2" function Touch(hit) 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)
To do this, you'll need to set a debounce and never change it back so it only works once ;)
Try this:
local Teleport = "Lentilkac58-Easy-Teleport-2" local Debounce = true -- Debounce is here function Touch(hit) if not Debounce then return end -- If Debounce is false this won't work 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) Debounce = false -- Set debounce to false so it won't work no more after teleporting wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end script.Parent.Touched:connect(Touch)
Hope this helped! Best of luck developer!