Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How To Make Teleport Pads Teleport Only Once?

Asked by 10 days ago
Edited 10 days ago

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)
0
It's called a debounce. RobloxWhizYT 1852 — 10d
0
^ Creacoz 62 — 10d

1 answer

Log in to vote
0
Answered by 10 days ago

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!

0
Thank you, it’s very appreciated! LightSunset 4 — 9d
Ad

Answer this question