Random player chooser

I want to make a random player chooser, where if the player is chosen, they are set onto a certain team, and the others on a separate team. How would I approach this?

local TeamNumber = 1
function Choose()
	if TeamNumber == 1 then
		TeamNumber = 2
		return game:GetService("Teams").Team1
	end
	TeamNumber = 1
	return game:GetService("Teams").Team2
end
local Players = game:GetService("Players"):GetPlayers()
local RandomPlayer = Players[math.random(1, #Players)]
RandomPlayer.Team = Choose()
1 Like