How Do I make a Walk Sound Repeat?

Hi Guys,
I am an Beginner at coding and I have made a script to play a sound when the player presses W, A, S, D But I can’t seem to get the sound to repeat if the player holds the button down??? I have tried many ways but just can’t do it. Please Help :smiley:

var Walk : AudioClip;

function Update () {
    if (Input.GetKeyDown ("w"))
    audio.Play();
    
    if (Input.GetKeyDown ("s"))
    audio.Play();
    
    if (Input.GetKeyDown ("a"))
    audio.Play();
    
    if (Input.GetKeyDown ("d"))
    audio.Play();
}

First make sure it knows the key down keyDown = true; then a audio.loop = true; in there then to stop the loop audio.loop = false;

Try something like…

if (Input.GetKeyDown ("What ever key goes here"))
    {
    audio.Play();
    keyDown = true;
    audio.loop = true;
    }else{
    keyDown = false;
    audio.loop = false;
    }

Note this is just a guess not sure if it will work.

The Code Is Done!!!

function Update () {
    if (Input.GetKeyDown ("w"))
    {
    audio.Play();
    audio.loop = true;
    }else{
    if (Input.GetKeyUp ("w"))
    audio.loop = false;
    }
}