Problem with Ontrigger

So, im trying to do a game where you have to collect coins and thats it, i can make the coin dissapear, get +1 in the counter, but i have a problem with a text.
So when i get close to the coin, a text show up in the scream, when i go away the message dissapear, but my problen is, that if i take the coin (destroy the object) the message get stuck in the screen, and i have to go to the next coin, get close and get away to make the message dissapear again, anyone have some idea of what im doing wrong?? here its what i use for that.

This one its to make the message just show up when i get close to the coin

public GameObject Boton;
public GameObject Personaje;

void Start () {
Boton.SetActive(false);

}
void OnTriggerEnter (Collider hit) {
if (hit.gameObject.tag ==(“Player”)) {
Boton.SetActive(true);
print (“Funciona”);}
}

void OnTriggerExit (Collider hit) {
if (hit.gameObject.tag ==(“Player”)) {
Boton.SetActive(true);}

}
}

So what im guessing is, that when the coin dissapear, the collider go with that object, so i
technically dont leave the collider, idk how to explain, hope someone can help me, and sorry for my english.

when an object is destroyed there is no call to “OnTriggerExit”.

You could use OnDestroy to handle the clean up though.

void OnDestroy()
{
Boton.SetActive(false);
}

https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDestroy.html

also, code tags please:
https://forum.unity3d.com/threads/using-code-tags-properly.143875/

its good enough :smile: better than my :smile:

Thank u so much, its working perfect now, really really thank u

Here i am again, hahaha, this time the problem it is with a door, i already did that when i get close i can see the message “press this key to open”, when i open, its shows me “press this key to close” but after that, i dont know how to make that message dissapear, i tried with OnTriggerExit in both texts, but its not working, Anyone have some idea? i did that in 2 different scripts, one its the one that make the door open and close, but it wasnt showing me the message the first time i went to the door, so i made another script, with OnTriggerEnter to show me the open message, and OnTriggerExit to both texts.