Play and stop sound

Hi, I’m new to unity, how can i make footsteps play while my character walk?
I have this script, but it doesn’t work. Please help?

function Update () 
 {
 	if(Input.GetButton("Horizontal") || Input.GetButton("Vertical"))
 		{
 		audio.Play();
 		}
 }

Something like this …

#pragma strict

var WalkingSound : AudioClip;

function Update () 
 {
    if(Input.GetButton("Horizontal") || Input.GetButton("Vertical"))
      {
      PlayerWalkSound();
      }
 }

function PlayerWalkSound(){

	audio.volume = 0.5;

	if (!audio.isPlaying){
		audio.clip = WalkingSound;
		audio.pitch = Random.Range(0.8f, 1.0f);
		audio.Play();
	}
}