Material[] Object reference not set when instantiating

I’m trying to fill an array of Materials with the materials from an array of GameObjects.

Right now, I have confirmed that GameObject array is filled with the correct gameobjects. I have also confirmed that it gets inside the for loop, but it stops right when I start to instantiate the Material array.

private Material[] aryOriginalMaterial;
private GameObject[] aryLukewarmGO;

aryLukewarmGO =  GameObject.FindGameObjectsWithTag("Lukewarm");
for (int i = 0; i < aryLukewarmGO.Length; i++)
{
    //Gets here, but stops at next line (next line is line 91 in the error)
    aryOriginalMaterial _= aryLukewarmGO*.transform.renderer.material;*_

}
In Unity, I get the error:
NullReferenceException: Object reference not set to an instance of an object
(wrapper stelemref) object:stelemref (object,intptr,object)
CharacterInput.GoInfrared () (at Assets/Scripts/Player/CharacterInput.cs:91)
CharacterInput.Update () (at Assets/Scripts/Player/CharacterInput.cs:42)

You need to set the size of the other array.

private Material[] aryOriginalMaterial;
private GameObject[] aryLukewarmGO;

This creates two reference variables to the type they are, like pointers. But they contain nothing.

aryLukewarmGO =  GameObject.FindGameObjectsWithTag("Lukewarm");

The method returns an array, it actually creates it and gives the address to the array reference. So you have your object.

but when you do :

aryOriginalMaterial _= aryLukewarmGO*.transform.renderer.material;*_

The one on the left has no storage location, it is just a null pointer/reference.
So either you need to create the array:
private Material[] aryOriginalMaterial = new Material;
But you need to know how big it should be or you use a list:
List materialList = new List();

First, the error tells you that you may want to check if aryOriginalMaterial and aryLukewarmGO exists.
Then the problem occurs because your Material array has not been initialized. You may want to use the “new” keyword to instantiate it.
I hope it helps,
Cheers.