How do you make a destroy command with timer and with tag.

Hey everyone! How do I make code so that a gameobject with a certain tag, “pawn” deletes after 5 seconds? Thank you in advance.

My current code (Not Working…)

Destroy(GameObject.FindWithTag("pawn"), 5);

If you want it to be destroyed 5 seconds after it was instantiated into the scene, then in the Start method, in a script attached to the pawn, do a Destroy(gameobject, 5);

If you want to trigger the 5 second countdown in all pawns, from another script, then something like this…

foreach(GameObject go in GameObject.FindGameObjectsWithTag("pawn"))
    Destroy(go, 5);

Hope this helps,

It works, thank you so much!