Change the colour of a specififc material?

I’ve read endless amounts of answers already pertaining to this topic, but none of them seemed to work correctly.

Basically, what I want to do is change the colour of two out of three materials on an object (But to different colours) and I can’t seem to get it to work properly. This is what I’ve tried:

foreach (Material matt in helmet.renderer.materials) {
					if (matt.name == "Helmet") {
						matt.color = Color.red;
						matt.SetFloat("_Shininess", 0.2f);
					}	
					else if (matt.name == "HelmetTop")
						matt.color = new Color (pc.EquippedHelmet.BrushColour.R, pc.EquippedHelmet.BrushColour.G, pc.EquippedHelmet.BrushColour.B);
				}
			}

When I play the game and look in the inspector, I can see it created a new instance of each material than I can change through the inspector, which works, but I want the code to change the colour of the two materials…

Thanks

You should try:

..
if (matt.name == "Helmet (Instance)")
..
..
else if (matt.name == "HelmetTop (Instance)")
..
..