Audio Repeating.

Hello,can you please fix my audio bug.I made code,when you click on text with box collider,audio sounds,but when i click it 2x fast same audio plays many times at same moment.Can you please fix it?I need to make,when you click text again,audio stops on second click.First click turns on sound,second turns off.

#pragma strict

var isQuitButton = false; 

var sound : AudioClip;

function OnMouseDown()
{
renderer.material.color = Color.red;
audio.PlayOneShot(sound);
waitForAudio(audio.clip.length);

}
function waitForAudio( time:float){
yield WaitForSeconds(time);
//change color back
renderer.material.color = Color.white;
}

Check the isPlaying variable, if it’s playing, don’t play it again, if not, give it a play and invoke the coroutine.

function OnMouseDown()
{
	// if audio is not playing, play it.
	if (audio.isPlaying == false) {
		renderer.material.color = Color.red;
		audio.PlayOneShot(sound);
		waitForAudio(audio.clip.length);
	} else {
        audio.Stop();
    }
}

function waitForAudio( time:float){
	yield WaitForSeconds(time);
	//change color back
	renderer.material.color = Color.white;
}