I am currently making a new game and I am trying to find a way if I can find usernames in a team. Not the number of people in the team but usernames.
local Players = Teams.TeamName:GetPlayers()
That will give you a list of all the players in the team. You can print the name of the players by doing
for _, Player in pairs(Players) do
print(Player.Name)
end
There are events for when a player is added / removed from the team. What is this going to be used for?
You forgotten to make a variable for Teams.
local Teams = game:GetService("Teams")
I assume that the retrieval of the Teams service was implied, since its indexing is required to actually do anything with teams (bar any other properties that reference Team instances). More of a minor concern than anything, but good to note anyway.
As Colbert said, Teams / Players as a variable is implied.
If you’ve got a solution from this post then please make whoever helped you as the solution.
I’ve always just run a loop through the current players and added them to a table if their teamcolor matched what I was looking for.
local teams = game:GetService('Teams')
for _, player in pairs(teams['Name of Team']:GetPlayers()) do
print(player.Name)
end