Why isn't my array printing the color of a localplayer's team?

I’ve been trying to print “Lime green” upon detecting a switch in teams, however, it is not printing anything, and there’s no errors to look back upon. I’ve tried changing the array order, and team names,. but still no luck… Below, has the array and the script I’m trying to print with.
Localscript

localPlayer:GetPropertyChangedSignal("Team"):Connect(function()
	for i, value in pairs(TeamArray) do
		if localPlayer.TeamColor == TeamArray[1] then
			print("Lime green")
			Icon.Active = true

Array

local TeamArray = { "Lime green", "Dark blue", "Maroon"}

“localPlayer.TeamColor” is a BrickColor value. Your code is attempting to compare a brickcolor value with a string. Change your array from strings to brickcolor values. I’ve modified your code a bit to fix it:

local localPlayer = game.Players.LocalPlayer
local TeamArray = {BrickColor.new("Lime green"), BrickColor.new("Dark blue"), BrickColor.new("Maroon")}

localPlayer:GetPropertyChangedSignal("Team"):Connect(function()
	for i, value in pairs(TeamArray) do
		if localPlayer.TeamColor == TeamArray[1] then
			print("Lime green")
			----
		end
	end
end)

Thank you for this, as it has solved my issue.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.