Someone gave me a script to fix this line:
if game.Teams.Survivors:GetPlayers() == nil then
Here is the script:
function getTeam(team) local players = game.Players:GetPlayers(); local teamPlayers = {}; for _, player in pairs(players) do if player.TeamColor == team.TeamColor then table.insert(teamPlayers, player); end end return teamPlayers; end
I have not idea what it means though and where to put it. Thanks!
getTeam
is function which takes in a team
, which is presumably a Team object (especially since we ask for its TeamColor in line 06).
It returns teamPlayers,
which from line 03 we see is a list, and from line 06 we can see contains Player objects.
From this, we can gather than getTeam
returns a list of players on a given a Team object's team.
Since you were asking to get the players from a given team, that would look like this:
getTeam(game.Teams.Survivors)
However, an empty list is not nil
it is just empty. We check if a list is empty by comparing its length to 0:
if #getTeam(game.Teams.Survivors) == 0 then
Thank you perci1 for noticing my typo; Game
should have been game
(corrected now)
I was clearly very distracted when I wrote this, my apologies. getPlayers
should have been getTeam
(corrected now)