After the end of the ‘intermission’ if the player has not chosen a team. What is the best way to assign them to the team with the least players.
The following code will check to see if a player is a on a team, if they are not then it will add them to the smallest player count one. You would add this at the end of your intermission script.
for _, plr in pairs(game.Players:GetPlayers()) do
if not plr.Team then
local low = 9999
local lowTeam
for _, team in pairs(game:GetService('Teams'):GetChildren()) do
if #team:GetPlayers()<low then
low = #team:GetPlayers()
lowTeam = team
end
end
plr.Team = lowTeam
end
end
4 Likes
Will test this out when I am home, tysm for your reply!
1 Like