Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with splitting players onto two teams?

Asked by 4 years ago

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

0
Do you want to include the problem you're having? SteamG00B 1633 — 4y

1 answer

Log in to vote
1
Answered by
BryanFehr 133
4 years ago
Edited 4 years ago

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

Ad

Answer this question