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

Will this code work to teleport all players touching a specific part when a button is pressed?

Asked by 4 years ago
Edited 4 years ago

I am trying to make an elevator that teleports everyone that is touching the inside of the elevator to the top floor. Once a button to close the door has been pressed then everyone touching that brick is teleported. I haven't been able to get it all to work and I need some help on this.

local Teleport = "Teleporter2"
    local time = 2 -- change to change cooldown
    function Touch(hit)
        wait (5)
        debounce = true
        local Pos = script.Parent.Parent:findFirstChild(Teleport)
        hit.Parent:moveTo(Pos.Position)
        wait(time)
        debounce = false
     end

    script.Parent.ClickDetector.MouseClick:Connect(Touch)

Answer this question