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

Any help w/ getting teleported to a part?

Asked by
FiredDusk 1466 Moderation Voter
9 years ago

This script is inside a part. When you touch it, it will bring you to those cords in the script. But it takes everyone in the game w/ you to the part at the cords.

function lol()
    local player = game.Players:GetPlayers()
for i = 1, #player do
    player[i].Character:MoveTo(Vector3.new(12.4, 10.649, -209.491)) --Change the cords to what you want to teleport to!  "(12.12.12))"
end
end

script.Parent.Touched:connect(lol)

If you could help me, THANK YOU VERY MUCH!

2 answers

Log in to vote
0
Answered by 9 years ago
function onTouch(hit) 
local human = hit.Parent:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(human.Parent)
    if human then
    player.Character:MoveTo(Vector3.new(12.4, 10.649, -209.491)) 
    end
end

script.Parent.Touched:connect(onTouch)

--you can even cut some of the code since you could just move the humanoid parent...

0
Thanks a lot! FiredDusk 1466 — 9y
0
EDIT YOUR CODE. PUT THE PLAYER LINE [line 3] INSIDE THE CONDITIONAL DigitalVeer 1473 — 9y
Ad
Log in to vote
0
Answered by
IcyEvil 260 Moderation Voter
9 years ago

I have Never used the MoveTo Method I use CFrame.

script.Parent.Touched:connect(function(hit)
    if hit.Parent then
        local hum = hit.Parent:findFirstChild("Humanoid")
        if hum then
            local torso = hit.Parent:findFirstChild("Torso")
            if torso then
                torso.CFrame = CFrame.new(12.4, 10.649, -209.491)
            end
        end
    end
end)

This is tested and works.

Answer this question