Reloading mechanism not working properly

The script that I’ve been using to create projectiles suddenly stopped working as planned. It used to have a period of time in between shots around one second long that you couldn’t fire the weapon as you were reloading it.

//this is for the different spots the gun fires out of and the projectile I instantiate
    public GameObject projectile;
public Transform firePoint;
public Transform firePoint2;
public Transform firePoint3;
public Transform firePoint4;
   //the floats i use to determine how fast and frequently you can fire
private float fireRate = 3f;
private float nextFire = 5f;

   void Update () {
                   if (Input.GetAxisRaw ("Fire2")>0 && Time.time > nextFire){
		Instantiate (projectile, firePoint.position, Quaternion.Euler (0,0,0));
		Instantiate (projectile, firePoint2.position, Quaternion.Euler (0,0,0));
		Instantiate (projectile, firePoint3.position, Quaternion.Euler (0,0,0));
		Instantiate (projectile, firePoint4.position, Quaternion.Euler (0, 0, 0));
		nextFire = Time.time + fireRate;

it’s supposed to make the time to reload the current time plus my fire rate. that way Time.time has to be greater than itself plus firerate in order to fire. I do not know where I went wrong with this.

You may need to change your logic so instead of continually firing when the Fire2 button is down and Time is higher than newFire which it is always going to be. Make it that it fires when Time.time < nextFire then you add the Time.time + fireRate so it fires for 3 firerates until time catches up again.

if (Input.GetAxisRaw (“Fire2”)>0 && Time.time > nextFire){

Change to:

if (Input.GetAxisRaw (“Fire2”)>0 && Time.time < nextFire){

Hope it helps.