So this script is supposed to print "Enough players" when both teams have enough players, and say "Not enough players" when neither team has enough players. However, the script is not working, and I don't know why. Can someone please help me?
Here's the script:
local team = game.Teams;
function getPlayers(teamColor)
local found = { };
for _,v in pairs(game.Players:GetPlayers()) do
if v.TeamColor == teamColor then
table.insert(found, v)
end
end
return #found
end
while wait() do
getPlayers(BrickColor.new('Bright green')).Changed:connect(function()
getPlayers(BrickColor.new('Bright red')).Changed:connect(function()
if getPlayers(BrickColor.new('Bright green')) > 0 and getPlayers(BrickColor.new('Bright red')) > 0 then
print('Enough players')
elseif getPlayers(BrickColor.new('Bright green')) == 0 or getPlayers(BrickColor.new('Bright red')) == 0 then
print('Not enough players')
end
end)
end)
end

3 comments
Would that code print a different message if the number of people on both teams changed?
If any of the teams' members went below 1 then it would print 'Not enough players'
But let's say that originally, one team had enough but the other didn't. It would print "Not enough players". But if the other team got enough players, would the script then print "Enough players"?