FireWeapon.cs not working

I have a script and whenever I hit the “Fire1” button, it doesn’t work.

Whats currently happening is its firing one bullet and then firing it again in a second.

Here is my script:

using UnityEngine;
using System.Collections;

public class FireWeapon : MonoBehaviour 
{
	public float fireRate = 0f;
	public Rigidbody bullet;
	public float speed = 0f;

	void Update ()
	{
		if (Input.GetButtonDown ("Fire1")) 
		{
			InvokeRepeating("Fire", 1f, fireRate);
		}
	}

	void Fire ()
	{
		Rigidbody pel = Instantiate (bullet, transform.position, transform.rotation) as Rigidbody;
		pel.AddForce (transform.forward * speed);
	}
}

Something like this will work.

public bool Activate = false;

if(Input.GetButton("Fire1")){
StartCoroutine (Shooting (1.0f));
		}
}


	

	IEnumerator Shooting(float waitTime){
		Activate = true;
		yield return new WaitForSeconds (waitTime);
		GameObject clone = Instantiate (FX120P, Barrel.position, Barrel.rotation)as GameObject;
		audio.PlayOneShot (ShootSFX);
		Activate = false;
	}
}

I got that from my code, it should shoot like every 1 second, change to your liking, I hope that works for you! P.S. - Change the FX120P to whatever your gameobject is called.

Try adding these to variables to your script

public float coolDownTime = 0.25f;
float timer;

then add this line and make sure it the first line in the update function

timer += Time.deltaTime;

then when you check for input you can also check if the timer is more than the cool down time:

if(Input.GetMouseButton(0) && timer >= coolDownTime){
timer = 0;
Shoot();
}

void Shoot(){
//stop audio source
//set audio source clip to shoot sound
//play audio source
//
//CODE TO INSTATIATE BULLET OR RAYCAST
//
}