Change team to all players in the server

I wanted to know how to change team to all players in the server, i have this script:

			player.Team = game.Teams.Lobby
			print("changed player.team to Lobby")

And i get player with this script:

game.Players.PlayerAdded:Connect(function(plr)

Does not work because player is the last player to join the server?

1 Like

you can do the following:

local player = game.Players:GetChildren()
for i = 1,#player do
      player[i].Team = game.Teams. Lobby
      print("Changed "..player[i].Name.." Team to Lobby")
end
1 Like

Or you can do this a similar way that is more understandable for beginners:

for _,player in pairs(game.Players:GetPlayers()) do
   player.Team = game.Teams.Lobby
   print("Changed "..player.Name.."'s team to Lobby.")
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.