Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What's wrong with this teleport?

Asked by
Zerio920 285 Moderation Voter
10 years ago
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

Log in to vote
2
Answered by
bbissell 346 Moderation Voter
10 years ago

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..

0
The deb IS the debounce... I'll try it though Zerio920 285 — 10y
Ad

Answer this question