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
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
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