I encounter this problem all the time, when I want to call a function in a while loop but only have it execute once. I always do something like this:

Code:
 

var sound_played = 0;

function play_my_sound()
{
if(sound_played == on) { return; }
sound_played = on; // when it tries to run the second time, it will return

...
}

...
while(whatever)
{
play_my_sound();
...
wait(1);
}
sound_played = 0; // when the loop is over, reset the variable




Hope that helps.