Raw Image changing texture in inspector but not in game.

Hey, there, I’m working on a dialogue system for my game and I wanted to have a picture of the character who is speaking in the corner next to the text. The dialogue system is working pretty much perfectly but for some reason the image of the character does not change. I can see it changing in the inspector but in game nothing changes. I’ve been toying around with it for hours now but I’m not great at coding and can’t seem to figure it out. I’ll put the entire script below and any help with this would be greatly appreciated.

public TextMeshProUGUI textDisplay;
public string[] sentences;
public RawImage imageSpace;
public Texture2D[] CharacterPortraits;
private int CurrentCharTexture;
private int index;
public float typingSpeed;
public GameObject ContinueButton;
public DialogueBegin DialogueBegin;

void Start()
{
    StartCoroutine(Type());
    Cursor.visible = true;
    Screen.lockCursor = false;
    imageSpace.GetComponent<RawImage>().material.mainTexture = CharacterPortraits[0];
    index = 0;
}

private void Update()
{
    if (textDisplay.text == sentences[index])
    {
        ContinueButton.SetActive(true);
    }
}

IEnumerator Type()
{
    foreach (char letter in sentences[index].ToCharArray())
    {
        textDisplay.text += letter;
        yield return new WaitForSeconds(typingSpeed);

    }
}

public void NextSentence()
{

    ContinueButton.SetActive(false);

    if (index < sentences.Length - 1)
    {
        //text
        index++;
        textDisplay.text = "";
        StartCoroutine(Type());

        //images
        CharImageChange();
    }
    else
    {
        textDisplay.text = "";
        ContinueButton.SetActive(false);
        DialogueBegin.End();
    }
}

private void CharImageChange()
{
    CurrentCharTexture++;
    imageSpace.GetComponent<RawImage>().material.mainTexture = CharacterPortraits[CurrentCharTexture];

}

For anyone interested, I figured it out myself.
Instead of using:

ImageSpace.GetComponent().material.mainTexture = textures[currentTexture];

use:

imageSpace.texture = textures[currentTexture];

that seemed to fix the problem.