Player visor color won't change?

I am trying to change a character’s visor (There’s a startercharacter that has one) when a player joins the game. It can pick between four different colors and each one has a corresponding visor texture. When I test it, I don’t get any errors but the visor does not change

game.Players.PlayerAdded:Connect(function(player)
	local character = player.CharacterAdded:Connect(function(character)



		local colors = {
			BrickColor.new("Bright red"),BrickColor.new("Sea green"),BrickColor.new("Electric blue"),BrickColor.new("Bright yellow")
		}

		character.Torso.BrickColor = colors[math.random(1,#colors)]
		if character.Torso.BrickColor == ("Electric blue") then
			character.Visor.Handle.Mesh.TextureId.Value = "http://www.roblox.com/asset/?id=42944896"
		else 
			if character.Torso.BrickColor == ("Bright red") then
				character.Visor.Handle.Mesh.TextureId.Value = "http://www.roblox.com/asset/?id=1163671"
			else
				if character.Torso.BrickColor == ("Bright yellow") then
					character.Visor.Handle.Mesh.TextureId.Value = "http://www.roblox.com/asset/?id=42580749"
				else
					if character.Torso.BrickColor == ("Sea green") then
						character.Visor.Handle.Mesh.TextureId.Value = "http://www.roblox.com/asset/?id=20264549"
				
	
			end
			end
			
			end
			end
	end)
end)

Can someone help?

You don’t need .Value after TextureId.
Script:

game.Players.PlayerAdded:Connect(function(player)
	local character = player.CharacterAdded:Connect(function(character)



		local colors = {
			BrickColor.new("Bright red"),BrickColor.new("Sea green"),BrickColor.new("Electric blue"),BrickColor.new("Bright yellow")
		}

		character.Torso.BrickColor = colors[math.random(1,#colors)]
		if character.Torso.BrickColor == ("Electric blue") then
			character.Visor.Handle.Mesh.TextureId = "http://www.roblox.com/asset/?id=42944896"
		else 
			if character.Torso.BrickColor == ("Bright red") then
				character.Visor.Handle.Mesh.TextureId = "http://www.roblox.com/asset/?id=1163671"
			else
				if character.Torso.BrickColor == ("Bright yellow") then
					character.Visor.Handle.Mesh.TextureId = "http://www.roblox.com/asset/?id=42580749"
				else
					if character.Torso.BrickColor == ("Sea green") then
						character.Visor.Handle.Mesh.TextureId = "http://www.roblox.com/asset/?id=20264549"
				
	
			end
			end
			
			end
			end
	end)
end)

Still doesn’t work. Any idea why?

Try taking away the brackets after saying if character.torso.BrickColor = (“Red”) <— these brackets for every colour.

On your lines that say
if character.Torso.BrickColor == ("Sea green"),

make this:
if character.Torso.BrickColor == BrickColor.new("Sea green")

You’re currently checking if the player’s torso’s BrickColor is a string, which it is never.
Here’s the fixed code for you!

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local colors = {
			BrickColor.new("Bright red"),
			BrickColor.new("Sea green"),
			BrickColor.new("Electric blue"),
			BrickColor.new("Bright yellow")
		}

		character.Torso.BrickColor = colors[math.random(1,#colors)]
		
		if character.Torso.BrickColor == BrickColor.new("Electric blue") then
			character.Visor.Handle.Mesh.TextureId = "http://www.roblox.com/asset/?id=42944896"
		elseif character.Torso.BrickColor == BrickColor.new("Bright red") then
			character.Visor.Handle.Mesh.TextureId = "http://www.roblox.com/asset/?id=1163671"
		elseif character.Torso.BrickColor == BrickColor.new("Bright yellow") then
			character.Visor.Handle.Mesh.TextureId = "http://www.roblox.com/asset/?id=42580749"
		elseif character.Torso.BrickColor == BrickColor.new("Sea green") then
			character.Visor.Handle.Mesh.TextureId = "http://www.roblox.com/asset/?id=20264549"
		end
	end)
end)
1 Like

Ah yes, my eyes overlooked that.

Alrighty, this works. I had to remove the “.value” after TextureId but otherwise after that it works as I intended. Thank you!