edit: I messed up the math in the percentage. Also tested the code this time, it should work. change percentage table to change the percentage of people in each team.
I did this for one of my games, I didn't test the code yet so let me know if it doesn't work
assuming you have the teams as
RedTeam
BlueTeam
YellowTeam
Also this assumes there is at least 3 people in the server
Players = game:GetService("Players")
blueteam = game.Teams.BlueTeam
yellowteam = game.Teams.YellowTeam
redteam = game.Teams.RedTeam
percentage = {blue = .05,red = .05, yellow = .90}
function AssignTeams()
local playerlist = Players:GetPlayers()
local totalplayers = #playerlist
local redpercent = math.ceil(totalplayers * percentage.red)
local bluepercent = math.ceil(totalplayers * percentage.blue)
local i = redpercent
while i > 0 do
playerlist[i].Team = redteam
i = i-1
end
i = bluepercent
while i>0 do
playerlist[i+redpercent].Team = blueteam
i = i-1
end
i = totalplayers - bluepercent - redpercent
while i> 0 do
playerlist[i+redpercent+bluepercent].Team = yellowteam
i = i-1
end
end
3 comments
I shall give it a test
Errors on line 9, changed it to "game.Players:GetPlayers()" but then it errors on line 20.
Oops I butchered my math .5+.5+.9 = 1 oops