This script partially works, help me find out what's wrong?
I have a round script, it loop checks if there are >1 player's, or <1 players, and if there's 2 players, starts the round. It works fine, except it teleports 1 player, instead of all of them.
Here's the script, try to tell me what's wrong please, I can't check output because it needs 2+.
02 | if game.Players.NumPlayers > 1 then |
05 | game.Workspace.lobby.timer.SurfaceGui.timelft.Text = "Starting New Round..." |
09 | game.Workspace.lobby.timer.SurfaceGui.timelft.Text = "Spawning Players..." |
13 | for i,v in pairs (game.Players:GetPlayers()) do |
14 | local coordinates = { Vector 3. new(- 80.9 , 3.2 , - 286.5 ), Vector 3. new( 1.64 , 3.2 , - 179.7 ), Vector 3. new( 83.5 , 3.2 , - 287.5 ), Vector 3. new( 2.44 , 3.2 , - 396.5 ) } |
15 | local randomCoor = coordinates [ math.random(#coordinates) ] |
16 | local knife = game.ServerStorage.Knife:Clone() |
17 | v.Character.Torso.CFrame = CFrame.new(randomCoor) |
18 | v.Character.Torso.Anchored = true |
19 | knife.Parent = v.Backpack |
21 | v.Character.Torso.Anchored = false |
26 | for i, v in pairs (game.Players:GetChildren()) do |
27 | v.Character.Humanoid.Health = 0 |
32 | game.Workspace.lobby.timer.SurfaceGui.timelft.Text = "Round Finished!" |
36 | if game.Players.NumPlayers < 2 then |
37 | game.Workspace.lobby.timer.SurfaceGui.timelft.Text = "This game requires 2+ Players." |
39 | game.Workspace.lobby.timer.SurfaceGui.timelft.Text = "This game requires 2+ Players.." |
41 | game.Workspace.lobby.timer.SurfaceGui.timelft.Text = "This game requires 2+ Players..." |
Can you try to see what's wrong? It only teleports 1 player. It kills all the players though, and gives all players the knife, when the round begins.