audio script problem

i tried to make so when i press the button it plays a random sound. When I keep on clicking on the button I want the first sound plays to the end and no other sounds start to play until the first sound is over.

var cake : AudioClip[]; 

function OnGUI()
{
	
		if (GUI.Button( Rect( 5, 50 , 310, 435), "Play Sound"))
		{
			if (!audio.isPlaying) 
			{
			audio.PlayOneShot(cake[Random.value * cake.length]);
			}
			else
			{
			}
		}			
}

Hi,
You can’t use PlayOneShot() for this as it will not affect isPlaying. What you should do is assign the clip to audio.clip and when it stops playing (isPlaying==false) assign the next clip and call Play().

regards,