Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How To Get The Names Of The Players On A Team?

Asked by 10 years ago

I've been trying to figure this out for about 5 hours and I can't get it no matter what I try. How would I get player's names that are only on one team? For example: List the names of the players on the red team, and list the names of the players on the blue team.

Can anyone help? It's driving me insane.

1 answer

Log in to vote
4
Answered by 10 years ago
function getplayers(teamname)
local list = {}

        local p = game.Players:GetPlayers()
local team = game.Teams[teamname].TeamColor
for i = 1,#p do
if p[i].TeamColor == team then
table.insert(list, p[i].Name)

end
end

return(table.concat(list,", ")

end

print(getplayers("Blue Team"))

this will give you a string list of players on a team.

0
Alright, thanks, not sure why I couldn't think of this. alienantics 15 — 10y
Ad

Answer this question