Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How To Make Teleport Pads Teleport Only Once?

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)

2 comments

0

It's called a debounce.

0

^

1 answer

✓ Accepted answer

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!

1 comment

0

Thank you, it’s very appreciated!

This discussion is preserved as it was. New answers, comments, and votes are closed.