because [for count] does not accept [int]?

I’m trying to send materials in the element using int, only it will not,

public List<GameObject> parts = new List<GameObject>();
public int element;


void Color(Material mat){
    for (int x = 0; x < parts.Count; x++)
    parts[x].GetComponentInChildren<MeshRenderer>().sharedMaterials[element] = mat;
	Material[] mats = GetComponent<MeshRenderer>().sharedMaterials;
	mats[element] = mat;
	GetComponent<MeshRenderer>().sharedMaterials = mats;
	{
		print("New Material");
	}

Renderer.sharedMaterial returns a single material. Renderer.sharedMaterials returns an array of the materials on said renderer.

The sharedMaterials array is a property which returns a “new array” when you read that property. Therefore changes to that array have no effect. You have to assign an array to the property in order to apply them to the renderer

Though it’s not really clear what you want to do here. I’m also not sure if you understand the purpose of applying multiple materials to the same renderer. This is only required when the mesh of a single object has multiple submeshes.

edit

Ok if i understood your video correctly you actually have two objects, each with 3 submeshes and 3 materials. You want to replace one of those materials on each object. Though it’s not clear if you want all objects to have the same materials, or if you just want to replace that one (element) material.

Anyways there are a few things you should do to simplify your code. Since you add references to your two “cubes” in the inspector, you should create a Renderer or MeshRenderer array instead of a GameObject array. That way you don’t have to use GetComponent.

If you want to assign the same materials to all objects you can grab the array from one of the objects, change the material you want and assign the array back to all the objects.

public List<Renderer> parts = new List<Renderer>();
public int element;
  
void Color(Material mat)
{
    Material[] mats = parts[0].sharedMaterials;
    mats[element] = mat;
    for (int x = 0; x < parts.Count; x++)
    {
        parts[x].sharedMaterials = mats;
    }
}

If you just want to replace that one material in each object but keep the individual materials on each object you have to do:

public List<Renderer> parts = new List<Renderer>();
public int element;
  
void Color(Material mat)
{
    for (int x = 0; x < parts.Count; x++)
    {
        Material[] mats = parts[x].sharedMaterials;
        mats[element] = mat;
        parts[x].sharedMaterials = mats;
    }
}

Keep in mind when you change the type of the parts list to List<Renderer> you have to reassign your two objects in the inspector.