[important] roblox teams script

Hi guys! I have a scripting problem, that I can’t solve, so I want you guys to give me some help. So basically my game is a team game, and I made two teams.

After making two teams, I added an “IntValue” both of them:

teamsStruct

It works fine. I set the MaxPlayer_red value to 25, and the MaxPlayer_blue value to 1.

My problem is that I cant figure out how to make a system that sorts out from all of the players (max 26 on server), just 1 player, and after selecting just ONLY ONE player, the system will put him to the Blue team, and the match/round begins.

Sorry for my bad english. And thanks all for your help! Bye, have a great day!

Discord: ati#1509

1 Like

I would call this function whenever your match begins, it should select someone randomly and put them on the blue team :slight_smile:

function choosePlayer()
	local Player = game.Players:GetPlayers()[math.random(#game.Players:GetPlayers())] 
	--print(Player), for debugging if you want
	Player.TeamColor = game.Teams.Blue.TeamColor 
end
1 Like

And which folder should I put this script in?

Put this in the round script, and when a new round starts, simply call choosePlayer().

1 Like

Thanks for your answer! Have a great day! :slight_smile:

1 Like