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

How do I fix my teleporters so that they don't rapidly tp me?

I have two teleporter pads and they work. Too well. Whenever I step on one I get rapidly ping-ponged between the two and it's very hard to get out of it.

This is the script I'm using for both (Replace TP1 with TP2 to represent other script)

function onTouch(part)
if part.Parent.Humanoid ~=nil then
part.Parent:MoveTo(script.Parent.Parent.TP1.Position)
script.Parent.Parent.TP1.Script.Disabled = true 
wait(2)
script.Parent.Parent.TP1.Script.Disabled = false
end
end
script.Parent.Touched:connect(onTouch)

1 answer

To do this we will create a debounce :

local Debounce = false -- It is false
function onTouch(part)
	if part.Parent.Humanoid ~=nil then
		if Debounce == false then -- If it false then
		Debounce = true -- Turn it to true, the script won't work if it is true
		part.Parent:MoveTo(script.Parent.Parent.TP1.Position)
		wait(2)
		Debounce = false -- Back to false
		end
	end
end
script.Parent.Touched:Connect(onTouch) 

If that didn't works then i will use another way by disable the other teleporter script


local TP1 = script.Parent.Parent.TP1.script -- the script of another teleport pad
function onTouch(part)
	if part.Parent.Humanoid ~=nil then
		TP1.Disabled = true-- Turn it to true, the script won't work if it is true
		part.Parent:MoveTo(script.Parent.Parent.TP1.Position)
		wait(2)
		TP1.Disabled = false -- Back to false
		end
	end
end
script.Parent.Touched:Connect(onTouch) 

5 comments

0

Not perfect but works well. Thanks!

0

It tps twice when u go on it.

0

I edited the answer, hope it help

0

Still doesn't work. Now the script doesn't TP me at all.

0

:/

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