How to check if TeamColor is equal to a color

Sorry if the title is confusing.
How do I detect the color of a team and insert it into a table. I have written the code below, but it doesn’t work. I get this error: white is not a valid member of BrickColor. What do I write instead of TeamColor.white?

	local playableTeams = {}
	for _, team in pairs(game.Teams:GetTeams()) do
		if team.TeamColor ~= team.TeamColor.white then
			table.insert(playableTeams, team)
		end
	end

Since TeamColor is a BrickColor value, when you check the value of TeamColor, you need to check it against another brick color value

local playableTeams = {}
for _, team in pairs(game.Teams:GetTeams()) do
	if team.TeamColor ~= BrickColor.new("PUT COLOR NAME HERE") then
		table.insert(playableTeams, team)
	end
end
6 Likes

Hey @gubuyguy3!

So TeamColor is a value in the form of BrickColor, and that’s how you can compare it!

Something like this:

if team.TeamColor == BrickColor.new("White") then
    print("Color is white!")
end

There’s tons of other ways to get a BrickColor than just it’s name though.

  • You can get it through RGB like this:

    BrickColor.new(Color3.fromRGB(255, 0, 0)) – red :slight_smile:

  • You can get it randomly like this:

    BrickColor.Random() – Random :T

  • You can call each colors specific function (not really sure why this is a thing but it is!) like this:

    BrickColor.White() – White :open_mouth:

  • Or you can get it from the really old system of color IDs. You remember how games would like tell you to put in a color id for some things? Well each BrickColor has an ID, and you can put that in like this:

    BrickColor.new(1014) – Teal :3

4 Likes

Thank you &RepValor for replying, greatly appreciated

1 Like