I'm making a murder mystery game but I don't know how to make 1 person join red team everyone else join the other team and after 120 seconds ( 2 minutes ) join the white team and then repeat i've had many attempts but none have worked..
my third attempt
local numPlayers = 0
for i, v in next, game.Players:GetPlayers() do
if v:FindFirstChild("TeamColor") == BrickColor.new("Bright red") then
numPlayers = numPlayers + 1
elseif v:FindFirstChild("TeamColor") ~= BrickColor.new("Bright red") then
numPlayers = numPlayers - 1
end
end
if numPlayers == 0 then
local player = game.Players:GetPlayers()
local pickedPl = math.random(1, #player)
pickedPl.TeamColor = BrickColor.new("Bright red")
for i, v in next, game.Players:GetPlayers() do
if v~=pickedPl then v:findFirstChild("TeamColor")=BrickColor.new("Team Color Name")
end
end
end -- ... I think.

2 comments
I find it easier to just use game.Players.NumPlayers.
That doesn't really have an effect on the the script works. It does the same thing, it just comes down to personal preference.