Unity UI element stays active when it should be hidden

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

public class Green : MonoBehaviour
{
    public Countdown objects;
    public Collider ustCollider;
    public TMP_Text informative;
    public GameObject player;
    public Camera mainCamera;

    private void Start()
    {
        informative.text = "+2 sec";
    }




    private void OnCollisionEnter(Collision collision)
    {

        if (collision.collider == ustCollider && collision.gameObject.CompareTag("Player")) // Kurtun etiketini kullanabilirsiniz.
        {
            informative.transform.position = player.transform.position + new Vector3(0, 20, 0);
            Vector3 position = informative.transform.position;
            position = mainCamera.WorldToScreenPoint(position) + new Vector3(0, -1860, 0);
            informative.transform.position = position;
            StartCoroutine(ShowMessage());
            Score.sayi++;
            objects.GetComponent<Countdown>().countdownTime += 2;
            Destroy(gameObject);

        }
    }



    private IEnumerator ShowMessage()
    {
        informative.gameObject.SetActive(true);

        yield return new WaitForSecondsRealtime(1);

        informative.gameObject.SetActive(false);
    }



}

Hey, After text shows up on screen it doesn't hidden. How can I fix it?

Those two things don’t work together. Coroutines run ON the MonoBehaviour instance you call StartCoroutine on. When you destroy the object the coroutine will die with it

ı delete destroy line but still text is showing on the screen.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class Green : MonoBehaviour
{
    public Countdown objects;
    public Collider ustCollider;
    public TMP_Text informative;
    public GameObject player;
    public Camera mainCamera;
    private void Start()
    {
        informative.text = "+2 sec";
    }
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.collider == ustCollider && collision.gameObject.CompareTag("Player")) // Kurtun etiketini kullanabilirsiniz.
        {
            informative.transform.position = player.transform.position + new Vector3(0, 20, 0);
            Vector3 position = informative.transform.position;
            position = mainCamera.WorldToScreenPoint(position) + new Vector3(0, -1860, 0);
            informative.transform.position = position;
            StartCoroutine(ShowMessage());
            Score.sayi++;
            objects.GetComponent<Countdown>().countdownTime += 2;
            gameObject.transform.position += new Vector3(0, 0, -9f);
        }
    }

    private IEnumerator ShowMessage()
    {
        informative.gameObject.SetActive(true);


        yield return new WaitForSecondsRealtime(1);

        informative.gameObject.SetActive(false);

    }
}

I fix it by adding gameObject.transform.position += new Vector3(0, 0, -9f); since I another destroyer on scene. In this way it will be destroy there.