How do I change my Materials on my second wall?

In my game, my walls are cubes that are textures with two materials, one named Wall1 for lighter walls and the other Wall2 for darker walls. Through this code, I am able to change Wall1:

public void RandomSkinLight(){

   int rand = Random.Range(0, 6);
   if (rand == 1){
      gameObject.GetComponent<Renderer>().material = SkinWallsLight[rand];
   } else if (rand == 2){
      gameObject.GetComponent<Renderer>().material = SkinWallsLight[rand];
   } else if (rand == 3){
      gameObject.GetComponent<Renderer>().material = SkinWallsLight[rand];
   }else if (rand == 4){
      gameObject.GetComponent<Renderer>().material = SkinWallsLight[rand];
   }else if (rand == 5){
      gameObject.GetComponent<Renderer>().material = SkinWallsLight[rand];
   }
}

I wish to use the same code in another function with different textures to change wall2 but I don’t know how to access it. Here are a couple of screenshots of my cube in the inspector:

With this Image I hope you all can understand. If there are any questions let me know! :slight_smile:

You can access it by getting all the material instances = myRenderer.materials[0] or [1] = 0 for your first material, 1 for your second material.
See Unity - Scripting API: Renderer.materials