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

How to make a team chooser?

I am making a game where the players can pick their teams, but theres a problem. All the players can just go on one team. What can I do to make the teams even and stop everyone from just joining one team.

local function countTeams( player )

	local rteam = 0
	local bteam = 0
	local neutral = 0

	for k,v in pairs(game.Players:GetChildren()) do

		if v ~= player then

			if v.Neutral then
				neutral = neutral + 1

			elseif v.TeamColor == teamRed then
				rteam = rteam + 1

			elseif v.TeamColor == teamBlue then
				bteam = bteam + 1

			else
				neutral = neutral + 1

			end
		end
	end

	return rteam, bteam, neutral

end

1 comment

0

Why the hell did people rate this down, what a holes

1 answer

✓ Accepted answer

Divide the number of players in the game by the number of teams and round up. Make sure that if there are that many players on one team, you can't join that team unless someone leaves it.

3 comments

0

?????

1

Clearly something is wrong with you?

0

How, I am not the best scripter man, what you said is pretty jiberish in scripting, i used a free model for my question

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