Machine Gun enabling/Disablingl

I have this script, where if you hold down what is the speed button in this, the machine gun becomes inactive, which works, but then it won't reactivate.

Here's the script

var projectile : GameObject;
var fireRate = 0.5;
private var nextFire = 0.0;
function Update () {
if (Input.GetButton ("Fire2") && Time.time > nextFire) {
nextFire = Time.time + fireRate;
clone = Instantiate (projectile, transform.position, transform.rotation);
if (Input.GetKeyDown(KeyCode.Mouse1)) {
if (Input.GetKeyUp(KeyCode.Mouse1)) {

if (Input.GetKeyDown(KeyCode.Space)) {
 enabled = false;
if (Input.GetKeyUp(KeyCode.Space)) {
 enabled = true;

Any ideas as to why this isn't working?

Try using getkey instead of getkeydown and up as there's a chance the game is missing the events.

That said it's more likely that by disabling the script you are no longer able to process the methods in the script. Better to use a boolean called canFire = false to stop it shooting.

if (Input.GetButton ("Fire1") && canFire) {

  canFire = false;
} else {
  canFire = true;