Image UI not enabling C# SOLVED

I have been working on this game over screen but when it came to enabling it when dead a problem came there were no errors in fact it seemed to be fine because I could Send a statement to the console when dead and it would work but the enabling of the UI would not. I would love some help with this if you can.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Damage : MonoBehaviour

    public int maxHealth = 5;
    public int currentHealth;
    public int DamageCount;

    public Image GameOver;
    public HealthBar healthBar;

    // Start is called before the first frame update
    void Start()
        currentHealth = maxHealth;
        DamageCount = 0;

    // Update is called once per frame
    void Update()
        if (Input.GetKeyDown(KeyCode.E))
            DamageCount += 1;
        if (DamageCount == 5)
            GameOver.enabled = true;


    void TakeDamage(int damage)
        currentHealth -= damage;




I found the answer to the problem here is what I changed so basically Instead of
GameOver.enabled = true; use
if the image is a component of a gameobject.

I have to assume that GameOver is somehow being set in the Unity Editor to an Image object that you have made a child of a canvas, but that is disabled in the Editor settings, correct?

If you enable it in the Editor, just as a test, does it display correctly?

Get it to display correctly there and then disable it and make sure you are referencing the correct Image instance when you code runs.