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

How do you separate players into even teams?

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

✓ Accepted answer

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()

2 comments

0

I'm trying to do this, but it says "Bright blue is not a valid members of Teams"

0

Oh, okay, I got it. Thanks!

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