✓ Accepted answer
You cannot reasonably do this inside the for loop.
You should consider each player, record if they are all on that team, then check after the loop.
Imagine you had players A, B, C. You want to know if they're all on team team.
That might look like:
allOnTeam = true
and a.TeamColor == team
and b.TeamColor == team
and c.TeamColor == team
(I include the true to show how to write this without making the first one special)
It's easy to make this into a for loop:
local allOnTeam = true
for _, player in pairs(game.Players:GetPlayers()) do
allOnTeam = allOnTeam and player.TeamColor == team
end
if allOnTeam then
else
end
Another way to approach this is to make a function that tells you who is on a team (and maybe who is not), and to look at the sizes of that.
Since you're probably interested in who is on what team at some point, that's a useful function to have.