(NullReferenceException) So Im Having A Issue With My Damage Flash Script

(first ever post sorry if I mess up)
First off I have only started coding about 2ish years ago so my knowledge isn’t the best (basic knowledge at best) and I probably do things in way I’m not supposed to or in a harder way.

So my damage flash code is supposed to do pretty much everything itself and all I have to do is set the material for the flash…

Problem is… it works… but also doesn’t? So it works completely fine as long as I have the enemy selected in the inspector. All the materials get stored and what not and the flash happens perfectly fine… But on enemies not selected in the inspector the skinnedrenders dont get stored.

Here is My Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyDamageFlash : MonoBehaviour
{
    public Material damageFlash;

    public MeshRenderer[] meshRenders;
    public SkinnedMeshRenderer[] skinRenders;

    public Material[] storedNormalMaterial;
    public StoredSkin[] storedSkinMaterial;

    public Material[] damageFlashSkin;

    [System.Serializable]
    public class StoredSkin
    {
        public Material[] storedSkinMats;
    }

    // Start is called before the first frame update
    void Start()
    {
        meshRenders = gameObject.GetComponentsInChildren<MeshRenderer>();
        storedNormalMaterial = new Material[meshRenders.Length];
        skinRenders = gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
        storedSkinMaterial = new StoredSkin[skinRenders.Length];
        damageFlashSkin = new Material[skinRenders.Length];
        for (int i = 0; i < damageFlashSkin.Length; i++)
        {
            damageFlashSkin[i] = damageFlash;
        }
        StartCoroutine(GetMaterials());
        //CauseFlash();
    }

    IEnumerator GetMaterials()
    {
        yield return new WaitForSeconds(1);
        {
            for (int i = 0; i < meshRenders.Length; i++)
            {
                storedNormalMaterial[i] = meshRenders[i].material;
            }

            for (int i = 0; i < skinRenders.Length; i++)
            {
                //storedSkinMaterial[i].storedSkinMats = new Material[skinRenders[i].materials.Length];
                storedSkinMaterial[i].storedSkinMats = skinRenders[i].materials;
            }
        }
    }

    public void CauseFlash()
    {
        for (int i = 0; i < meshRenders.Length; i++)
        {
            meshRenders[i].material = damageFlash;
        }

        for (int i = 0; i < storedSkinMaterial.Length; i++)
        {
            skinRenders[i].materials = damageFlashSkin;
        }

        StartCoroutine(ResetFlash());
    }

    IEnumerator ResetFlash()
    {
        yield return new WaitForSeconds(0.1f);
        {
            for (int i = 0; i < meshRenders.Length; i++)
            {
                meshRenders[i].material = storedNormalMaterial[i];
            }

            for (int i = 0; i < skinRenders.Length; i++)
            {
                skinRenders[i].materials = storedSkinMaterial[i].storedSkinMats;
            }
            yield return null;
        }
    }
}

And here is the error I get for the enemies not selected in the inspector:

NullReferenceException: Objcet reference not set to an instance of an object
EnemyDamageFlash+d_8.MoveNext() (EnemyDamageFlash.cs:51)

I understand that this null ref usually means something is missing but that missing thing gets filled in if the object is selected in the inspector.

So instead of public class storedSkin… I guess it needed to be public struct storedSkin… I dont really know the difference but it seems to work for now.