How do I manage the collisions of a child object without parent?

I’m working on a little 2D project involving an enemy, a player, and a sword. The enemy has a RigidBody2D and a collider, the player has a RigidBody2D and a collider, the sword is a child of the player and only has a collider. Just as a basic system for debugging, I have it set up that if the enemy collides with the player, the player gets destroyed. If the sword collides with the enemy, the enemy gets destroyed. The problem is that now the collision follows the hierarchy up to the first RigidBody which therefore destroys the player when the sword collides with the enemy. Anyone knows how I can fix this?

You can put player and sword into a gameobject. And set different tag for player and sword.