play sound when kill enemy

hi Im building a 2d shooter and want to add a sound to a script that kills enemies but cant get it working.

This is the script

var hitPoints = 10;

function can_die (damage) {
hitPoints -= damage; if( hitPoints
< 1 ) { Destroy(gameObject, 0.0);
} }

Ive tried adding


with an audio source but cant egt it working.

Any Ideas?


the moment you destroy the object the script attached to it also get destroyed so no script no sound played

give a yield before destroying the object

function DestroyAfterYield(time : float)
    yield WaitForSeconds(time);