Shooting every second issue

I have a shooting script that only allows the player to shoot one projectile every second (so they can’t spam). Except if I wait a bit, on the first shot, the player shoots 2 projectiles. How can I fix this? Here’s my code:

//variables for shooting
var canShoot:boolean=true;
var timeToShoot:float=1;
var currentShootingTime:float=0;

//projectile array
var projectiles : Transform[];
enum ProjType { RPG, RPBR,BR1 }
var currProj = ProjType.RPG;

//Initializing currentTime
function Start()
{
	currentShootingTime=Time.time+timeToShoot;
}

function FixedUpdate()
{
	//connects to my animator controller
	var Tmation:Animator=GetComponent(Animator);
	
	//Projectile Selection
	if (Input.GetKeyDown("1")) currProj=ProjType.RPG;
	if (Input.GetKeyDown("2")) currProj=ProjType.RPBR;
	if (Input.GetKeyDown("3")) currProj=ProjType.BR1;
	
	if (Input.GetButtonDown("Jump") && canShoot){
		//if space bar is pressed, normal shoot animation
		Tmation.SetBool("Fire", true);
	
		var projectile=Instantiate(projectiles[currProj], transform.FindChild("CannonPoint").transform.position, Quaternion.identity);

		//tags projectile, gets speed of tank and multiplies it by 3000 for the RPG
		switch(currProj) {
			case ProjType.RPG:
			projectile.gameObject.tag="projectile";
			projectile.rigidbody.AddForce(transform.forward*4000);
			//recoil
		rigidbody.AddRelativeForce(Vector3(0,0,-1000000));
			break;

			case ProjType.RPBR:
			projectile.gameObject.tag="BouncyRocket";
			projectile.rigidbody.AddForce(transform.forward*50000);
			projectile.rigidbody.AddForce(transform.up*7000);
			//recoil
		rigidbody.AddRelativeForce(Vector3(0,0,-1000000));
			break;
			
			case ProjType.BR1:
			projectile.gameObject.tag="BuildingRocket";
			projectile.rigidbody.AddForce(transform.forward*500);
			projectile.rigidbody.AddForce(transform.up*500);
			break;
		}
		
		//shooting off for 1 second
		canShoot=false;
		
		}else{
			Tmation.SetBool("Fire", false);
		}
		if (!canShoot){
			checkShoot(); 
		}
}

//shooting timer
function checkShoot()
{
	if(Time.time > currentShootingTime)
	{
		canShoot = true;
		currentShootingTime = Time.time + timeToShoot;
	}
}

I appreciate your help. -Hyperion

The problem is the last piece of code:

  //shooting off for 1 second
       canShoot=false;
 
 
      // ...

      if (!canShoot){
         checkShoot(); 
      }

You just shot a shot and set canShoot to false. When you call checkShoot() now, the time will be updated, but canShoot will also be set to true as well. Thats why you can place two shots at once if you wait over your timeframe.

To make sure that you can only fire a shot when it’s allowed you should wrap your shooting code with an if-statement like this:

if (Input.GetButtonDown("Jump") && checkShoot()) {  // when the button is pressed and we may shoot right now
     // we want to shoot now. Let's first record the time when we will be allowed to shoot next.
    currentShootingTime = Time.time + timeToShoot;

    // do the rest of your shooting code. (basically insert your code here)
}

// This function simply checks if the current time is past the next allowed shooting time. If so , it returns true, otherwise it returns false.
function checkShoot()  
{
    return (Time.time > currentShootingTime);
}

Basically your first approach failed because you had two checks that checked for the same information but could diverge (e.g. canShoot == true vs Time.time >= timeToShoot). By removing one of the checks and only using the Time.time >= timeToShoot you will no longer get divergent results and the code will work as inteded. I would almost always refrain from using boolean flags for state decisions as it is easy to make mistakes there.