I need a script that, when run, will sort only people in a ROBLOX group into two teams. I have tried this, but the issue is that It ends up sorting unevenly.
local players = game.Players:GetPlayers() for i = 1, #players do local player = players[i] if player:IsInGroup(XXXXXX) then if i >= #players / 2 then player.TeamColor = BrickColor.new("Really red") else player.TeamColor = BrickColor.new("Really blue") end end end
local groupMembers = {} for i, v in pairs(game.Players:GetChildren()) do if v:IsInGroup(XXXXXX) then table.insert(groupMembers, v) end end for i, v in ipairs(groupMembers) do if i%2 == 0 then v.TeamColor = BrickColor.new("Really Blue") else v.TeamColor = BrickColor.new("Really Red") end end
That should do it.