Noob Question: Play Specific Audio

Hello, This is a real noob question.

But what I want, is to be able to apply an audio clip to a variable, and play it depending on a boolean:

var AudioClip : Audio //(?)\\
var Play : false

then if play is true:

if(Play == true){
play AudioClip;
}

I'm guessing I will need to add an AudioSource to the object too.

Add an audio source to your object. Then you can play the sound in two ways.

You can use PlayOneShot if you have an audio clip.

var clip : AudioClip;
var play = false;

if ( play )
{
    audio.PlayOneShot( clip );
}

Or you can set the clip directly on the Audio Source in the inspector call Play:

var play = false;

if ( play )
{
    audio.Play( );
}

However, beware that setting the play flag to true and not resetting it will cause your sound to play every time that piece of code is run. This can crash your editor (I think).