how to destroy the gameobject on which the script is in unity code example
Example 1: destroy gameobject unity
Destroy(this.gameObject);
Example 2: how to destroy a gameobject in c#
Destroy(gameObject); // destroys the game object attached to the script