A text apears on the screen when you enter a trigger

Hey guys,
I need a script that do the following , thank youuu <3
A text apears on the screen when you enter a trigger and goes away when you exit the trigger , and its not a GUItext , thanks

So for the text to appear, I used UIText, so I’ll give you an example of this to start with.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TextTrigger : MonoBehaviour
{

public Text keycardText;
private bool closeEnough = false;

// Start is called before the first frame update
void Start()
{
    closeEnough = false;
    keycardText.text = " ";
}

// Update is called once per frame
void OnTriggerEnter(Collider col)
{
    if (col.tag == "Player")
    {
        closeEnough = true;
        keycardText.text = "Keycard";
    }
}

}
This basically makes the text appear when it enters the collider. However, I unfortunately am still trying to figure out the disappearing aspect. If I figure it out, I’ll let you know :wink: