✓ Accepted answer
Ok, so I've written a 'lil something for ya.
Here is a function that'll check if a team has no players!
local redteam = game.Teams.Red
local blueteam = game.Teams.Blue
function checkbalance()
local getredteam = getPlayers(redteam)
local getblueteam = getPlayers(blueteam)
if getredteam[1] == nil then
print("Red has no players!")
elseif getblueteam[1] == nil then
print("Blue has no players!")
else
print("There are still players on each team!")
end
end
function getPlayers(team)
local players = {}
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
if player.TeamColor == team.TeamColor and not player.Neutral then
table.insert(players, player)
end
end
return players
end
checkbalance()
Call the checkbalance() function to check for no players on a team.
Hope this helps!
1 comment
I'm not understanding the "getPlayers" part. It prints that is a nil value