Problem loading sprite via script.

I wrote this script, not sure where I went wrong :confused:

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

public class Character : MonoBehaviour
{
    public GameObject defAv;
    public Image m_Image;
    public Sprite ajAv;
    public Sprite remyAv;
    public Sprite thebossAv;
    public Sprite xbotAv;
    public Sprite ybotAv;
 
    public Text defTx;
 
    void Start(){
        m_Image = defAv.GetComponent<Image>();
    }
 
    public void Aj(){
        m_Image.sprite = ajAv;
        defTx.text = "Aj";     
    }
 
    public void Remy(){
        m_Image.sprite = remyAv;
        defTx.text = "Revy";     
    }
 
    public void TheBoss(){
        m_Image.sprite = thebossAv;
        defTx.text = "The Boss";     
    }
 
    public void XBot(){
        m_Image.sprite = xbotAv;
        defTx.text = "X-Bot";     
    }

    public void YBot(){
        m_Image.sprite = ybotAv;
        defTx.text = "Y-Bot";     
    }
}

I get errors like this:
NullReferenceException: Object reference not set to an instance of an object
Character.Function Name Here (at Assets/Scripts/Panels/Menu/Add/Character.cs:[Line no. Here])

Hi @RealPpTheBest ,

It looks like you didn’t assign any Image to your public “m_Image” variable in the inspector window, before executing the code.

If you’re unsure, please share here a screenshot of how the inspector window of this component looks like.

Good luck with it!