Need help with raycast gun firerate

Hi guys i know this is asked alot but please help.
I need to put a fire rate on my raycast gun script…
I’m the kind of person who learns with examples so this script is salvaged from many scripts and was modified to fit my needs.

using UnityEngine;
using System.Collections;

public class GunHit
{
public float damage;
public RaycastHit raycastHit;
}

public class RaycastGun : MonoBehaviour
{
public float fireDelay = 0.1f;
public float damage = 100;
public string buttonName = “Fire1”;
public float maxBulletSpreadAngle = 15.0f;
public float timeTillMaxSpreadAngle = 1.0f;
public AnimationCurve bulletSpreadCurve;
public LayerMask layerMask = -1;

private bool readyToFire = true;
private float fireTime;

// Use this for initialization
void Start ()
{

}

// Update is called once per frame
void Update ()
{
	if(Input.GetButton(buttonName)) //GetButtonDown for semi-auto, GetButton for automatic fire
	{
		fireTime += Time.deltaTime;
		if(readyToFire)
		{
			GetComponent<AudioSource>().Play();

			RaycastHit hit;

			Vector3 fireDirection = transform.forward;

			Quaternion fireRotation = Quaternion.LookRotation(fireDirection);

			Quaternion randomRotation = Random.rotation;

			float currentSpread = bulletSpreadCurve.Evaluate(fireTime/timeTillMaxSpreadAngle)*maxBulletSpreadAngle;

			//float currentSpread = Mathf.Lerp(0.0f, maxBulletSpreadAngle, fireTime/timeTillMaxSpreadAngle);

			fireRotation = Quaternion.RotateTowards(fireRotation,randomRotation,Random.Range(0.0f,currentSpread));

			if(Physics.Raycast(transform.position,fireRotation*Vector3.forward,out hit,Mathf.Infinity,layerMask))
			{
				GunHit gunHit = new GunHit();
				gunHit.damage = damage;
				gunHit.raycastHit = hit;
				hit.collider.SendMessage("Damage",gunHit,SendMessageOptions.DontRequireReceiver);
				readyToFire = false;
				Invoke("SetReadyToFire", fireDelay);
			}
		}
	}
	else
	{
		fireTime = 0.0f;
	}
}

void SetReadyToFire()
{
	readyToFire = true;
}

}

Create a float

Call it FireTimer or whatever else you like

Create another float, call it FireRate

Put the following line in the Update :

FireTimer += Time.deltaTime * FireRate;

add:

if (Input.GetButton (“buttonName”) && FireTimer >= 1 )

{

Shoot the raycast and do all the other magic;

FireTimer = 0;

}

Basically, you only allow the Raycast to be fired if you click the mouse AND the FireTimer float is equal or greater to 1. And since you multiply Time.deltaTime by the float FireRate, you can easily adjust how fast you want the gun to be able to fire. At the end of all that, you just have to make sure that FireTimer is reset back to 0, so the countdown can start over and prevent your gun from being fired too soon.