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

How do I teleport all the players that are touching a part with a clickdetector?

Asked by 4 years ago

I am trying to teleport all the players that are touching a part to another part when a click detector is activated. I'm not sure what else I need to add or take away from this script for it to work. I also have this script inserted into the part that I want everyone to be touching when they get teleported. That part is neither a child or parent of the part that I want to be clicked and it causes the teleportation. Do I need to make them either a child or a parent?

local Teleport = "Teleporter1"
    function Touch(hit)
        wait (5)
        local Pos = script.Parent.Parent:findFirstChild(Teleport)
        hit.Parent:moveTo(Pos.Position)

     end

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

Answer this question