Unable to attach materials on MeshRenderer

public Material Head = new Material[6];

public GameObject createMob(GameObject prefab)
{
    GameObject mob = new GameObject();
    GameObject head = new GameObject();

    if(true)
    {
        head.AddComponent<MeshRenderer>().sharedMaterials = Head;
    }
}

So this is my code. It should simply assign a materials on mob head but when I run the game the size of materials array in inspector is 6 but the materials are not set. Materials in Head are assigned manually in inspector so I don’t understand why it doesn’t work

I just tested your code and it works.