Okay so this is supposed to select a random player to be chosen for the red team and put the rest of the players on the other team.
var.players.Value is the number of players in the game.
it should select a random number out of the number of players and then should catch that number on the loop while letting the other users pass to the green team.
The problem is that it's putting everyone on the red team.
Thanks in advance for the help!
local spawnPlayers = function()
local chosenPlayer = math.random(var.players.Value)
for i,player in pairs(game.Players:GetChildren()) do
if chosenPlayer == i then
player.Character.Head:destroy()
player.TeamColor = BrickColor.new('Bright red')
else
player.Character.Head:destroy()
player.TeamColor = BrickColor.new('Medium green')
end
end
end

1 comment
Still having the same issue where they are both put on the same team... It doesn't make any sense at all! the script should work??? Thanks for the tip on NumPlayers though, I had no idea that existed!