Is Clockwork's teleport script outdated?

Recently i’ve beed making a game in which there are portals and when you go inside it brings you to a different level ( it has the same concept as Speed Run 4) I decided to use clockwork’s teleport script, but it seems to have a problem. If the player uses the teleport once and then resets he will not be alble to use it again which seems pretty wierd. I am a very bad scripter so I may have made a few mistakes.

Here is the script:

local Teleport = "Part1" function Touch(hit) --Indicates that the Part has been Touched. 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 --Checks Debounce. local Pos = script.Parent.Parent:findFirstChild(Teleport) --Gets the Part to teleport to. hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end --Takes you there and Ends the Function. script.Parent.Touched:connect(Touch) --Listens out for Touchers.

If the script is intended to teleport characters only, it seems that it has a lot of unnecessary bits in it. A teleport script is as simple as this:

local TeleportPart1 = script.Parent
local TeleportPart2 = OtherPartLocation
local Debounce = false

local function OnTouch(Object)
    If not Debounce then
        Debounce = true
        if Object.Parent:FindFirstChild(“Humanoid”) then
            Object.Parent:SetPrimaryPartCFrame(TeleportPart2.Position)
        end
        wait(1)
        Debounce = false
    end
end

TeleportPart1.Touched:Connect(OnTouch)

I do not understand the other bits of the code you have provided. Why is it needed to check if the part is locked?

1 Like

Thank you for the help!
:slightly_smiling_face:

1 Like

I updated the code I posted, I forgot to reset the debounce :grimacing:

Edit:
Updated it again… It should surely work now :slight_smile: