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

What are the different ways to create a list of the players on a certain team?

Read above. :). I'm looking for different ways so I can choose the one that works best for me. Thank you!

1 answer

✓ Accepted answer

Use game.Players:GetChildren(), run a check to see which team they're in, then use table.insert() to put their name/player in the Team's table. Beforehand, create X tables, for how many teams there are.

Example:

local blueTeam = {}
local redTeam = {}

while true do
	wait(30)
	local p = game.Players:GetChildren()
	for i = 1,#p do
		if p[i].TeamColor == game.Teams.RedTeam.TeamColor then
			table.insert(redTeam,p.Name)
		elseif p[i].TeamColor == game.Teams.BlueTeam.TeamColor then
			table.insert(blueTeam,p.Name)
		end
	end
wait()

1 comment

0

Thank you.

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