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)) {
audio.Play();
}
if (Input.GetKeyUp(KeyCode.Mouse1)) {
audio.Stop();
}
if (Input.GetKeyDown(KeyCode.Space)) {
enabled = false;
}
if (Input.GetKeyUp(KeyCode.Space)) {
enabled = true;
}
}
Any ideas as to why this isn't working?