How come when the player runs into the coin it won't destroy?

void OnTriggerEnter(Collider theTrigger){
if (theTrigger.gameObject.name == “Player”){
PlayerHitScript.coin_count += 1;
Destroy(this.gameObject);
}
}

The code works by a coin drops after you kill a monster, and if you run into the coin it’s supose to be destroyed. The code works if you run into the coin within like a second of killing the monster but if you kill it, wait a couple seconds, then run into the coin it just stays there and doesn’t disappear, anyone know why?

The way you have this scripted is rather inefficient, on top of that you’re using Unity library terms that don’t exist. Try something like this

void OnTriggerEnter(Collider)
{
    if(Collider.tag == "Player")
    {
        transform.Destroy();
    }
}

In this you’ll have to set the physical player’s tag to “Player”