List of members in a certain team

Yesterday, I’ve received a job about making a gang system using teams, but I ran into a problem when it comes to the list of gang members.

So, I want to make a list of members in a certain team, how would you go about it?
would you use values? or send information with remote events? I would like to hear your opinion on it.

1 Like

You can loop through all players in a team and create a corresponding Frame for each player

If what you mean is just get the members in a team then you can use tables

You can try doing

local teamTable = {}
if player.Team.Name == teamName then
    table.insert(teamTable, player)

Obviously, it’s not a full script but you can use this method roughly to try and get it. I don’t think it’ll be the most efficient method though.

Take a look at this if you want to find more effective ways to do it. The solution provides a pretty detailed solution. All you need to do is just implement table.insert if you want it to be on a table.

1 Like

The team object actually has a function used to retrieve a table of all the players in that team.

local Team = game:GetService(“Teams”).Gang
local PlayersOnTeam = Team:GetPlayers() --A table