OnTriggerEnter2D works in one gameobject and not in other

Hello everyone.
I have two monsters gameobject, each of them has an empty gameobject children with a collider and a script on it. The first monster does the OntriggerEnter2D of that script perfectly. The second monster doesn’t.

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.layer == enemylayer && this.gameObject.layer == playerlayer)
        {
            other.GetComponent<EnemyController>().DamageRecieved(damage);
            player_mana.GetComponent<Slider>().value = player_mana.GetComponent<Slider>().value - 1.0f;
        }
        if (other.gameObject.layer == playerlayer && this.gameObject.layer == enemylayer)
        {
            other.GetComponent<PlayerController>().DamageRecieved(damage);
        }

Line 10 is what gives the error on the second monster. Error is NullReferenceException: Object reference not set to an instance of an object
I don’t get it at all…

Well, the error is because it can’t find a playercontroller on this other object. So the real question is which object is it detecting. You’ll probably have to put some debugging in there to figure that out. Since you’re doing something with children and parents, my guess without further info is it is either getting the parent or child of where the playercontroller is.