Is it possible to destroy a gameobject from a child gameobject's script?

I am trying to destroy the parent Gameobject from the child. The parent is “Opossum” that has a patrol and attack script attached to it. The Rigidbody2D is “OposBody” The child only has the OpossHealth script attached to it. Unless… should I put the trigger inside of the if statement instead of this way?
139882-child-parent.jpg

    public int enemyHealth, currentHealth, playerdmg;
    GameObject PTarget, OpossBody, Opossum;

    public void OnTriggerEnter2D(Collider2D OpossBody)
    {
        if (OpossBody.gameObject.name == "Opossum")
        {
            if (currentHealth <= 0)
            {
                Destroy(Opossum.gameObject);
            }
        }
    }

Assuming that I understood what is it all about… You are trying to destroy GameObject that is stored in Opossum variable, but there’s no check as to what that variable holds. (That variable doesn’t have to be your “Opossum”) to fix :

public int enemyHealth, currentHealth, playerdmg;
 GameObject PTarget, OpossBody, Opossum;
 
 public void OnTriggerEnter2D(Collider2D OpossBody)
 {
     if (OpossBody.gameObject.name == "Opossum")
     {
         if (currentHealth <= 0)
         {
             Destroy(OpossBody.gameObject);
         }
     }
 }

That way you will destroy gameObject that entered trigger (if it’s name is “Opossum” and currentHealth <=0)


Disclaimer:

Comparing names is not the best way of checking if given GameObject is the one you’re looking for (as comparing strings is performance expensive, and if you were to just change the name of GameObject whole script falls apart), instead it’s better to use something like if (OpossBody.GetComponent<ScriptNameThatIsExclusiveForThatGameObject>() != null) (In other words, if given GameObject has that script f.eg. “PlayerInputHandler” or like “PlayerSomething” then you are sure that GameObject is a player).