Reloading wont work

I have put this script together from various other scripts and it works ok until I run out of ammo and I reload. It dosent reload, I cant really say anything else it just dosent reload, can anyone help me?

var amountOfShots = 8;
var reloadTime = 1.5;
var refireRate : float = 0.1;

function ShotPoller()
{
    while(true)
    {
        if(Input.GetButton("Fire1"))
        {
            Shoot();
            yield WaitForSeconds(refireRate);
        } else {
            yield;
        }
    }
}

function Start()
{
    StartCoroutine(ShotPoller());
}
    
if(Input.GetKeyDown("r")){
    Reload();
}

function Reload (){
    yield WaitForSeconds(reloadTime);
    amountOfShots = 8;
}

var shotSound : AudioClip;
var bloodPrefab : Transform;
var sparksPrefab : Transform;
var hit : RaycastHit;
var range = 500;

function Shoot (){
    if(amountOfShots > 0){
        amountOfShots--;
        if(shotSound){
            audio.PlayOneShot(shotSound);
        }
        if (shotSound) audio.PlayOneShot(shotSound); 
        var hit: RaycastHit;
        if (Physics.Raycast(transform.position, transform.forward, hit)){
            var rot = Quaternion.FromToRotation(Vector3.up, hit.normal);
            if (hit.transform.tag == "Enemy"){ 
                if (bloodPrefab) Instantiate(bloodPrefab, hit.point, rot); 
                hit.transform.SendMessage("ApplyDamage", 20, SendMessageOptions.DontRequireReceiver); 
            } else { 
                if (sparksPrefab) Instantiate(sparksPrefab, hit.point, rot);
            }
        }
    }
}

You need an ‘Update’ somewhere in there. As it is, (because of Javascript weirdness, in a sane language this wouldn’t even compile but that’s a whole different rant), you are checking for the ‘reload’ button in ‘Awake’- which executes exactly once, and only before the game even begins. You should wrap that into an ‘Update’ function-

function Update()
{
    if(Input.GetKeyDown("r")){
        Reload();
    }
}

Or, better still- put it into your shoot poller!

while(true)
{
    if(Input.GetButton("Fire1"))
    {
        Shoot();
    }
    if(Input.GetKeyDown("r")){
        Reload();
    }

    yield;
}

Then, rejig shoot a little to put the ‘WaitForSeconds’ into that, and call ‘Reload’ if it’s out of bullets!

function Shoot (){
    if(amountOfShots > 0)
    {
        // do all of the shooting which already works
        yield WaitForSeconds(refireRate);
    } else {
        Reload();
    }
}