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

How do i make Players Teleport to different determined locations?

Asked by 10 years ago
P1 = game.Workspace.P1
    P2 = game.Workspace.P2
    P3 = game.Workspace.P3
    P4 = game.Workspace.P4
    P5 = game.Workspace.P5
    P6 = game.Workspace.P6
    P7 = game.Workspace.P7
    P8 = game.Workspace.P8
    wait(2)
    players = game.Players:GetChildren()
    for i = 1,#players do
    if i == 1 then 
        players[1].CFrame = P1.CFrame
    end
    a = game.Workspace:WaitForChild(player.Name)
    a.Torso.CFrame = game.Workspace.P1.CFrame

    end

I know that this script is wrong but i dont know how i would go about this

2 answers

Log in to vote
0
Answered by 10 years ago

Based off of Huner's answer, but improved and fixed the code.

wait(2) -- Wait in seconds
x =  -- Gets players
for i,v in ipairs(game.Players:GetPlayers()) do
    if v.Character then
        v.Character.Torso.CFrame = game.Workspace.P1.CFrame
    end
end
Ad
Log in to vote
-1
Answered by
Sublimus 992 Moderation Voter
10 years ago

Here, let me clean this up and explain it for you:

You don't need all those variables, you can just find the parts by the index number. Also, the player doesn't have a CFrame value, it's the character that does.

wait(2) -- Wait in seconds
x = game.Players:getChildren() -- Gets players
for i = 1, #x do -- Loops through players
    if x[i]:findFirstChild("Character") then
        x[i].Character.Torso.CFrame = game.Workspace:findFirstChild("P"..i) --Finds part based on index number
    end
end
0
Character is a property, not a child, so findFirstChild will never return what you want. Fix this to change my downvote to an upvote. TheLuaWeaver 301 — 10y
0
how would this be fixed? Chaserox 62 — 10y
0
It would work as I use it for many other scripts. It's fine, he made a mistake. Sublimus 992 — 10y

Answer this question