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

Why won't player's visor texture change depending on torso brickcolor?

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 = "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)

1 answer

Instead of using else everytime, use elseif. It's better and will probably make everything work.

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