Using waitforseconds to put delay between gunshots

HELP! I’m using unity 4.6.9, and I have a script to make a gun shoot. It works perfectly, except you can fire as fast as you want, as in several bullets per second. I want to have like a one second delay between the shots that you can fire. However, after trying again and again to get a yield waitforseconds (5); to work, I haven’t been able too. The script below does nothing. Or rather, it does exactly as it does normally, with absolutely no delay. I’ve even tried ramping the delay up to 100, and it still doesn’t do anything. I’ve been trying for days!!!

var projectile : Rigidbody;
var speed = 10;

function wait() {
	yield WaitForSeconds(1);
}
function Update () {
	if(Input.GetMouseButtonDown(0)) {
		clone = Instantiate(projectile, transform.position, transform.rotation);
		clone.velocity = transform.TransformDirection(Vector3 (0, 0, speed));
		audio.Play();
		Destroy (clone.gameObject, 5);
	}
	wait();
}

Please help!!!

This will work for you

var projectile : Rigidbody;
var speed = 10;

// the time allowed between shots (in seconds or parts thereof)
// the smaller the value the faster shots can occur
var timeBetweenShots = 1;

// flag to determine if a shot was fired
private var shotFired = false;

function FireShot()
{
    // fire the shot
    clone = Instantiate(projectile, transform.position, transform.rotation);
    clone.velocity = transform.TransformDirection(Vector3 (0, 0, speed));
    audio.Play();
    Destroy (clone.gameObject, 5);

    // do not allow another shot until timeBetweenShots has elapsed
    yield WaitForSeconds(timeBetweenShots);

    // reset the shot flag so shooting can resume
    shotFired = false;
}

function Update ()
{
    if ((!shotFired) && (Input.GetMouseButtonDown(0)))
    {
        // immediately set the shot flag so another shot can not be made
        shotFired = true;
        FireShot();
    }
}