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

How do you separate players into even teams?

Asked by 10 years ago

Okay, so how would I separate players into random, but even teams?

Like, I have 10 players. What would I do to separate them randomly into even teams? With 5 on each one?

Thanks!

1 answer

Log in to vote
2
Answered by 10 years ago

I looped through every player in a for loop. Then I checked if the index is divisible by two. I did this because every second number is divisible by two. So this would divide the players in two.

local One = Game.Teams["Bright blue"]
local Two = Game.Teams["Bright red"]

function Seperate()
    for o,n in pairs(Game.Players:GetPlayers() do
        if o %2==0 then
            n.TeamColor = One.TeamColor
        else
            n.TeamColor = Two.TeamColor
        end
    end
end

Seperate()
0
I'm trying to do this, but it says "Bright blue is not a valid members of Teams" ImmenseKassing 120 — 10y
0
Oh, okay, I got it. Thanks! ImmenseKassing 120 — 10y
Ad

Answer this question