Yeah, I've never been good with randomizing, but this is what I've got but it doesn't work?
local function SplitPlayers() local players = {} for _, player in pairs(game.Players:GetPlayers()) do if player.TeamColor == BrickColor.new("Medium stone grey") then table.insert(players, player) end end local redTable = {} local blueTable = {} local redPlayers = math.floor(1/2 + #players * 4/6) local bluePlayers = #players - redPlayers for i = 1, redPlayers do local player = table.remove(players, math.random(#players)) table.insert(redTable, player) player.TeamColor = BrickColor.new("Really red") end for i = 1, bluePlayers do local player = table.remove(players, math.random(#players)) table.insert(blueTable, player) player.TeamColor = BrickColor.new("Bright blue") end end
local teams = {"Bright blue","Bright red"} local number = 1 for _, player in pairs(game.Players:GetChildren()) do player.TeamColor = BrickColor.new(teams[number]) number = number + 1 if number > #teams then number = 1 end end
Change what's inside the teams table to the team color you want, just make sure they are BrickColor's.
wait(10) -- Change 10 to the amount of time you want this to happen for i, v in pairs(game.Teams["White Team"]:GetPlayers())do v.Character.Head:Destroy() end
Change White Team to the team were you will get all the players. Might not be a team randomizer but it works.
I have the perfect idea! I write script only in ServerScriptService:
local teams = {'Really red', 'Really blue'} local team = {{''},{''}} -- Red and Blue team game.Players.PlayerAdded:Connect(function(plr) -- Add player in random team local plrs = game.Players:GetChildren() if #team[1] == #team[2] then local choosed = math.random(1,2) table.insert(team, choosed, plr) plr.TeamColor = BrickColor.new(teams[choosed]) elseif #team[1] < #team[2] then table.insert(team, 1, plr) plr.TeamColor = BrickColor.new(teams[1]) elseif #team[1] > #team[2] then table.insert(team, 2, plr) plr.TeamColor = BrickColor.new(teams[2]) end end) game.Players.PlayerRemoving:Connect(function(plr) -- Remove player team if plr.TeamColor == 'Really red' then for i = 2, #team[1] do if team[1][i] == plr.Name then table.remove(team, 1, i) break end end else for i = 2, #team[2] do if team[2][i] == plr.Name then table.remove(team, 2, i) break end end end end)