Bullet script not working!!! Pls tell me how to make a bullet script.

using UnityEngine;
using System.Collections;

public class FP_shooter : MonoBehaviour
{
public GameObject bullet_prefab;
float bulletimpulse = 100000f;
public Rigidbody rb;

// Use this for initialization
void Start ()
{
	rb = GetComponent<Rigidbody> ();
	GetComponent<Rigidbody> ().velocity = transform.forward;
}

// Update is called once per frame
void FixedUpdate ()
{
	if (Input.GetButtonDown ("Fire1")) 
	{
		Camera cam = Camera.main;
		GameObject thebullet = (GameObject)Instantiate (bullet_prefab, cam.transform.position, cam.transform.rotation);

	rb.AddForce (transform.forward * bulletimpulse);
	}
}

}

You have to pit the key if thing in the update function. The key state is checks once per frame and update is called once per frame just do it like this :

using UnityEngine; using System.Collections;

public class FP_shooter : MonoBehaviour { public GameObject bullet_prefab; float bulletimpulse = 100000f; public Rigidbody rb;

 // Use this for initialization
 void Start ()
 {
     rb = GetComponent<Rigidbody> ();
     GetComponent<Rigidbody> ().velocity = transform.forward;
 }

void Update(){
 if (!firestate && Input.GetButtonDown ("Fire1")) 
     { firestate = true 
}

}
 
 // Update is called once per frame
 void FixedUpdate ()
 {
     if (firestate) 
     {
         Camera cam = Camera.main;
         GameObject thebullet = (GameObject)Instantiate (bullet_prefab, cam.transform.position, cam.transform.rotation);
     rb.AddForce (transform.forward * bulletimpulse);
firestate = false ; 
     }
 }
}