play an audio clip in an if statement

I have a dialogue that gets turned on and off with if statements. I wanted to know how you could make an audio file play only once when in a if block

	if(StartingQuest == true)
		
	  audio.clip = intro;
    audio.Play();
	
	if(QuestOne == true)
	audio.clip = firstQuest;
    audio.Play();
	
	if(QuestOne_done == true){
		audio.clip = Getting_sword;
		 audio.Play();

Hi Babilinski ,

Here is your answer. its very simple. just make function for everything and call it.

public AudioClip gameClip;
	
void Update()
{
	if(StartingQuest)
	{
	       playMusic();
	}
}
	
void playMusic()
{
	audio.clip = gameClip;
	audio.Play();
	audio.volume = 1.0f; // optional
	audio.loop = false; // for audio looping
}

You have to change the value of the boolean variables that you have after intro clip has played. Initialise all boolean variables except StartingQuest to false and then make use of yield WaitForeSeconds:

if(StartingQuest == true){

      audio.clip = intro;
      audio.Play();
      yield WaitForSeconds (audio.clip.length);
      QuestOne = true;  
}    

if(QuestOne == true){  //now questone can play
    audio.clip = firstQuest;
    audio.Play();
    yield WaitForSeconds (audio.clip.length);

    //now question one has completed
    QuestOne_done = true;
}

if(QuestOne_done == true){  //play what is to be played when QuestOne is done
     audio.clip = Getting_sword;
     audio.Play();    
     //then again 
     yield WaitForSeconds (audio.clip.length);
}