Audio toggle switch is silent on first button press?

I have created a button that starts playing a loop when it is pressed. That was simple to do! Now I’ve been looking for an elegant way to just click that same button again and stop the loop. I searched through the forums and found a clever hack to do this, by just muting the volume if the volume is 1.0 and increasing it if it is 0.0. However this isn’t working exactly as I had planned! On the 1st click of the button there is no audio. Only on the 3rd click does the audio show up. I think I understand why it is not working but I’m not sure what is really the best solution in this case. I have tried a couple other approaches, but so far I’ve not figured it out.

var sound : AudioClip;

function OnMouseDown() {
 audio.Play(); 

if (audio.volume == 1.0)
audio.volume = 0.0;
else
audio.volume = 1.0;

 }

Thanks!

EDITED/HERE IS THE FIXED AUDIO TOGGLE BELOW/

var sound : AudioClip;

var onoff = false;

function OnMouseDown() {

if (!onoff) {

audio.Play();

} else {

audio.Stop(); }

onoff = !onoff;

}

It may not be 1 or 0 at start, check the Inspector, but you know, there is a ‘mute’ field you can set true or false.