Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer
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.

1 comment

0

Alright, thanks, not sure why I couldn't think of this.

This discussion is preserved as it was. New answers, comments, and votes are closed.