Reloading Function in Script not doing anything.

My game runs and I don’t get any errors of any kind, but I can’t seem to get my reloading function to work. Nothing happens when I press the “r” key. I think it has to do with me calling the reload function in a spot the game can’t detect, but I googled my problem dozens of times and I can’t come up with why it wouldn’t work calling it in the Update. Any advice/suggestions would be appreciated.

var speed = 10;
var maxbullets : int = 6;
var totalBullets: int = 12;
var reloadtime: int = 2;
var transfer : int = 6 - maxbullets;

function Update() {
	Fire(); 
	
	Reload(); 
	
}

function Fire() { 
	if (maxbullets > 0); 
	
		if(Input.GetButtonDown("Fire1"))
{
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection(Vector3 (0, 0, speed));

Destroy(clone.gameObject, .25);

maxbullets -= 1; 
GameObject.Find("BulletCount").guiText.text = ""+maxbullets;

	}
}

function Reload() { 

    if(totalBullets > 0);
    	
    if (transfer > totalBullets) { transfer = totalBullets; }

		if(Input.GetKeyDown("r"))    
    	
    		yield WaitForSeconds (reloadtime);
  			animation.Play("RevolverReloadAnimation");
    {
	
	maxbullets += transfer;
	totalBullets -= transfer;
	
	GameObject.Find("TotalBullets").guiText.text = ""+totalBullets;

	}
}

Thanks!

The curly braces for the if check with the Input.GetKeyDown(“r”) is not correctly set up. Without the curly braces the only thing happening when you hit the button is the yield statement. The animation.Play is running each update which means the animation begins at the beginning every frame, and therefore you do not see anything happening.

You need to move the starting curly brace from line 40. to line 37, and you would probably want to play animation before the yield or nothing will happen before the reload time is up.

if(Input.GetKeyDown(“r”))

should go in update(). Your input check is never being called. That is unless Reload() is being called elsewhere in your code, and on every game loop.