Unity does not recognize reload animation for gun

I am trying to make a reload script for my gun, so that when I hit ‘R’ my gun reloads, but the thing is that the animation and the reseting of current ammo doesn’t work. What’s the problem here?

var SMG : GameObject;
var smg_script : MonoScript;
var Ammo = 54;
var CurrentAmmo = 54;
var Wait : float;






function Update () {

if(Input.GetButtonDown("Fire1")){


   CurrentAmmo -= 1;




  if(CurrentAmmo == 0){
 
   
    Reload();
   
   
   }
   
   else
   
   
   
   if(Input.GetButtonDown("R")){
     if(CurrentAmmo < 54){
   
      Reload();
   
   
   
       }
     }
  }








}


function Reload () {


SMG.animation.Play(); 

yield WaitForSeconds(Wait);
CurrentAmmo = 54;











}

Your second if statement is nested in the first. It will be easier to see if you adjust your tabbing.

Your code looks like this at the moment.

if(button) {
    if(ammo) {

    } else if(button2) {

    }
}

For the second button to be checked, you need to hold down the first one (which I assume is not what you’re expecting)