How to avoid "Destroy(gameObject)" to interrupt message cycle.

I got 2 scripts in a gameobject (an enemy), one of them manages the HP and the other one adds to the score when the enemy is damaged.

Damage is done by sending a message to the enemy that both the “hpScript” and the “scoreScript” receive as long as it is not the last blow. If the enemy dies with a hit, no score is added. I have comented the “Destroy(gameObject)” line in the “hpScript” and then score is added normally.

So it turns out that the Destroy command interrupts the message and it is not being sent to the rest of the scripts in the game object.

I have though about a couple of workarounds, such as adding score in the death event itself, but they feel kind of dodgy and I wonder if there is any “clean” solution, any option to the sendmessage o destroy that would let the message do the rounds around all scripts before the object is destroyed.

You’re going to need to rearrange some things. Have the score added before the destroy. Maybe separate the scripts between different game objects, so you can destroy the components separately.