audio loop when I click the MouseButtonDown(0)

Hi guys was wondering how I could loop a shooting sound while I am holding the MouseButtonDown(0), I succeded in making it sounds one time but then there is no looping, could you help me?
this is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ShootSound : MonoBehaviour {

public AudioSource AudioSource;
private AudioClip clip;
public GameObject gunPrefab;

void Update () {
	if(Input.GetMouseButtonDown(0))
    {
        AudioSource.loop = true;
        playShot();           
    }
}
void playShot()
{
    AudioSource = gunPrefab.GetComponent<AudioSource>();
    clip = AudioSource.clip;
    AudioSource.PlayOneShot(clip);
}

}

try this…but note that you’d have to use a separate game object just for the AudioSource so that it doesn’t disable other things besides the audio. Also, just a reminder, Input.GetMouseButtonDown(0), will NOT return true while the button i held down, it will only return true the first frame, i.e. only once in Update. I used GetMouseButton in the code below, you may also just want to use that call instead of using the whole example

Edit: forgot to mention some key settings. To use the code below, configure your AudioSource to play on wake and make sure loop is also checked.

AudioSource anAudioSource;
        void Update() {
            if (Input.GetMouseButton(0)) {
                anAudioSource.gameObject.SetActive(true);
            } else if (anAudioSource.gameObject.activeInHierarchy) {
                anAudioSource.gameObject.SetActive(false);
            }
        }