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

What's wrong with this teleport?

local deb = require(Workspace.deb)

script.Parent.Touched:connect(deb(function(hit)
	if hit.Parent:FindFirstChild("Humanoid")
		then
		hit.Parent.Torso.CFrame = hit.Parent.Torso.CFrame + Vector3.new(0,100,0)
	end
end))

This script teleports the player 100 studs above him. For some reason, this teleports the player higher than 100 studs, and sometimes kills the player instead! If I use

		hit.Parent.Torso.CFrame = script.Parent.CFrame + Vector3.new(0,100,0)

It's less glitchy, but from the player's perspective it looks a little less smooth. Any ideas?

1 answer

This might mean you need a debounce. This should solve it. Here is an example:

local deb = require(Workspace.deb)
local debounce = false -- Sets debounce to false

script.Parent.Touched:connect(deb(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and debounce == false then -- Checks for debounce
	local debounce = true -- Sets debounce to true
        hit.Parent.Torso.CFrame = hit.Parent.Torso.CFrame + Vector3.new(0,100,0)
	wait(3)
	local debounce = false --Sets debounce to false
    end
end))

If this doesn't work, Im not sure what the issue is. Hope this helps..

1 comment

0

The deb IS the debounce... I'll try it though

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