Hello, I’m wondering how to make a script that auto matches a team per round(balanced), I have 3 teams in-game, Red, Blue and Voters, and Lobby team. I’m not sure how to do this, please help!
You code check the amount of players in a team before letting the player in the team.
A silly way I thought of doing this: assuming you’re running through an array of players, use modulus on the index of ipairs and assign the team based on if the number can divide evenly into 2 or not.
Here’s an example with pure code:
local redTeam = {}
local blueTeam = {}
local players = {"foo", "bar", "garply", "baz", "robux"}
for i = 1, #players do
local team = i%2
table.insert(team == 1 and redTeam or blueTeam, players[i])
end
print(table.unpack(redTeam))
print(table.unpack(blueTeam))