Destroying an object from its script.

I am trying to destroy a gameobject from a script attached to it. what do?

i am checking the remaining hp of a character after they are hit and if their hp is <1 i want to destroy them. the problem is that i dont know how to access the object that holds the script from within it. i cant use find because this script is generic and will be attached to every character. is there a getparent function or something i can use?

thanks for the help!
(btw im working in c#)

Nope! You use

Destroy(gameObject);

to destroy the object which the script is attached directly to.

You can also use

Destroy(transform.parent.gameObject);

to destroy the object’s parent, or

Destroy(transform.root.gameObject);

to destroy the object right at the top of the hierarchy!