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

How can I make random teams assign?

I want to make players get randomly assigned to teams. I have one script for this, but its not really that good. Is there a better way to do this? Here is my script:

local assign = 1
for i,v in pairs(game.Players:GetChildren()) do
if assign = 1 then
assign = 2 
v.Team.BrickColor = BrickColor.new("Black")
else

assign = 1
v.Team.BrickColor = BrickColor.new("White")
end

1 answer

I hope this works for you, because it worked for me.

for key, value in pairs(game.Players:GetChildren()) do
	local TeamAssign = math.random(1, 3) --custom amount of teams
	if TeamAssign == 1 then
		value.TeamColor = BrickColor.new("Bright red")--your team here
        elseif TeamAssign == 2 then
	       value.TeamColor = BrickColor.new("Bright blue") --your team here 
        elseif TeamAssign == 3 then
	       value.TeamColor = BrickColor.new("Bright green")--your team here
        end
end

Here you go. Make sure that every team you put in this script exists in your game. Sincerely, DominusInfinitus

5 comments

0

-1 for not having an explanation at all.

0

BOI! I took his code and the only difference is the math.random function!

0

you are being abusive

0

Ill give you plus I dom:).

0

Thank you, and if you don't understand, just say it now so I can edit.

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