So I am trying to retrieve all the players in a team to then be used in future programs. While testing I found out that the player is outputted three times instead of once. I have tried multiple variations off loops and have consulted the documentation for ‘:GetPlayers()’. I have consulted with a friend and it may be a replication issue but I am not totally sure.
Code:
wait(5) --Ensure the player is loaded before running the script
local teams = game:GetService("Teams")
local police = teams.Police:GetPlayers()
local nhs = teams.NHS:GetPlayers()
local fire = teams.Fire:GetPlayers()
for i = 1,#police do
print(police[i])
end
for i = 1,#nhs do
print(nhs[i])
end
for i = 1,#fire do
print(fire[i])
end
Output:
I would highly appreciate if anyone could help me with this as I am stuck for ideas.