So I'm using this script to determine how many players on a team. It works fine, except I want the script to tell if the number of people on a team changes, and then reacts to that. 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
local greenNum = getPlayers(BrickColor.new('Bright green'))
local redNum = getPlayers(BrickColor.new('Bright red'))
if greenNum > 0 and redNum > 0 then
print('Enough players')
else
print('Not enough players')
end
end

2 comments
That would work perfectly, and DONT double post. And before you ask, YES it would react if one of the teams' number of members went below 1
It's not working. I'm testing it on online. I had both teams have 0, it printed the message, and now that both teams have at least one person, the script from when they didn't have any people isn't reacting to the change. I'm sorry for double posting