how to destroy an object throught a script code example
Example 1: destroy gameobject unity
Destroy(this.gameObject);
Example 2: how to destroy in unity
// To remove a GameObject use the function 'Destroy()'
Destroy(gameObject);
Destroy(this.gameObject);
// To remove a GameObject use the function 'Destroy()'
Destroy(gameObject);