tank engine audio script

I,m trying to attach two sounds to my tank model through an audio source
One for idle and one for moving. i have tried to modify a few scripts but cant seem to get any of them work but this one. The problem is it plays the running sound one time
then cuts out. what i want to achieve is one idle sound for when it stops and a running sound for when i press the up key and then stop it when i release it and go back to the idle sound.

var iddle: AudioClip;

var acceleration: AudioClip;

var ralenti: AudioClip;

var rec: AudioClip;

var radio: AudioClip;

function Update() {

if (Input.GetKeyDown (“up”))

audio.PlayOneShot(acceleration);

if (Input.GetKeyUp (“up”))

audio.Pause();

if (Input.GetKeyDown (“down”))

audio.PlayOneShot(rec);

if (Input.GetKeyUp (“down”))

audio.Pause();

if (Input.GetKeyDown (“o”))

audio.PlayOneShot(radio);

}

PlayOneShot will play your clip… once!

You need two(or more) AudioSource components on your object, then use Play instead of PlayOneShot. You could fade quickly between one sound and the other with a custom fade function. Check out this post where I’ve answered a similar question : adding audio source through code - Questions & Answers - Unity Discussions

And do read about the AudioSource component!