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

Player Table Help?

for i,p in pairs(game.Players:GetChildren()) do
		if p.TeamColor ~= "White" then
			players = {p}
		end
	end

I'm trying to make a table of all the players in the game that aren't on the White team. I tried doing this, but it only gets the first player indexed rather than all the players.

for i,p in pairs(game.Players:GetChildren()) do
		if p.TeamColor ~= "White" then
			players = {players + p}
		end
	end

That breaks the script entirely. Help please?

1 comment

0

I don't know if this would have anything to do with it, but try doing if p.TeamColor ~= BrickColor.new("White") then

1 answer

✓ Accepted answer

because your rewriting over it everytime. Your not adding to it (you tried in the second but thats not right)

Use table.insert!

for i,p in pairs(game.Players:GetChildren()) do
	if p.TeamColor ~= "White" then
		table.insert(players,p)
	end
end

Hope i helped! If i did Up my answer and accept it :)

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