Simple fade script unexpectedly fading all UI elements,Simple Fade script unexpectedly fading all UI elements

hey guys, I have this script I made (pulled off the internet) to fade my announcement box when it is active. When it is done fading, I wanted to then deactivate it, and reset the alpha channel. When I testing the following code, when the announcement box was set active, all objects in my UI canvas ALL fade out… I wouldn’t assume this is expected behavior, but I am a noobie…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Announcements : MonoBehaviour
{
    public Text announcementText;

    private Color alphaColor;
    private float timeToFade = 3.0f;


    // Start is called before the first frame update
    void Start()
    {
        alphaColor = this.gameObject.GetComponent<Image>().material.color;
        alphaColor.a = 0;
    }

    // Update is called once per frame
    void Update()
    {
        if (this.gameObject.activeInHierarchy == true)
        {
        
            this.gameObject.GetComponent<Image>().material.color = Color.Lerp(this.gameObject.GetComponent<Image>().material.color, alphaColor, timeToFade * Time.deltaTime);

        }

        //something about can select more than one enemy with this skill, maybe even quips from bosses

    }
}

why is this code fading out all of my UI elements on the canvas!! what is the solution to this problem? My announcement box is not the only thing with the image component, but it is the only object with this script attached, and even my silders are all fading away. i also tried to replace this.gameobject with gameobject.find(“announcementbox”) but that didnt fix it either. :frowning:

try to instantiate a public GameObject Announcement ;
and then use Announcement.GetComponent instead os this.Gameobject.GetComponent
(Dont forget to assign gameobject in inspector)