Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help with splitting players onto two teams?

Im having a problem with splitting players. Ive looked through a lot of dev forums, but found none that answer this. Most of them are just talking about an error.

function assignTeams()
    local balanceTolerancy = math.floor(#plrs / 2)

    for i = 1, balanceTolerancy do
		plrs[i].Team = Red
    end

    for i,v in pairs(plrs) do
		if not plrs[i].Team == Red then
   			plrs[i].Team = Blue
		end
	end
end

1 comment

0

Do you want to include the problem you're having?

1 answer

✓ Accepted answer

Hello!

The ROBLOX Developer hub has created a good article on Team balancing, and how to use it in your game! I suggest you do more research here; as most of what you can find on the DevForums will sometimes be specific to players games, and their own ways they've done it. If you are learning; the best bet to use is the ROBLOX Developer Hub as it's the standard way most new comers to LUA Learn!

Here is the link - https://developer.roblox.com/en-us/articles/team-balancing

~BryanFehr

BryanFehr#3070

This discussion is preserved as it was. New answers, comments, and votes are closed.