Reload Gun?

Hi, there. Can someone help me with an script… It is from a unity preset game. Is an shooter. How can i add reload function, and bullet count. I have the reload sound (3 sec duration).
Here is the script.
using UnityEngine;

Add a int CurBullets,MaxPerClip and a ReservedAmmo

then at :
if(Input.GetButton ("Fire1") && timer >= timeBetweenBullets && Time.timeScale != 0) { Shoot (); }
make it :

if(Input.GetButton ("Fire1") && timer >= timeBetweenBullets && Time.timeScale != 0) {
if(CurBullets > 0){
            Shoot ();
}else{
Reload();
}
        }

Then create a:

void Reload()
{
float shotsFired;

    shotsFired = BulletsPerClip - CurBullets;

    TotalBullets = CurBullets + reservedAmmo;
    if (TotalBullets < BulletsPerClip)
    {
        CurBullets = TotalBullets;
        isReloading = false;
        print("End Of Reload");
        TotalBullets = 0;

    }
    else
    {
        CurBullets = BulletsPerClip;
        reservedAmmo -= shotsFired;
        isReloading = false;
        print("End Of Reload");
        TotalBullets = 0;
    }
}

Then for waiting for the reload you need to make an IEnumerator waiting for the reload anim to end

public class AmmoBehaviour : MonoBehavior
{
public int ammo;
public int Maxammo;
public int Clipammo;
public int Clipsize;
int Rammo;
public bool canFire;
public bool isReloading;

// Update is called once per frame
void Update()
{
    if (Clipammo != 0 && isReloading == false)
    {
        canFire = true;
    }

    if (Input.GetKeyDown(KeyCode.Mouse0) && canFire && !this.tag.Contains("Auto"))
    {
        Clipammo--;
    }

    if (Input.GetKey(KeyCode.Mouse0) && canFire && this.tag.Contains("Auto"))
    {
        Clipammo--;
    }

    if (Input.GetKeyDown("r") && !isReloading)
    {
        isReloading = true;
        StartCoroutine(ReloadDelay());
    }

    if (Clipammo < 0) Clipammo = 0; canFire = false;
    if (ammo < 0) ammo = 0;

}

IEnumerator ReloadDelay()
{
    yield return new WaitForSeconds(3);
    if (ammo > Clipsize - Clipammo)
    {
        Rammo = Clipsize - Clipammo;
        Clipammo = Clipsize;
        ammo = ammo - Rammo;
    }
    else
    {
        Rammo = Clipsize - Clipammo;
        Clipammo = Clipammo + ammo;
        ammo = 0;
    }
    isReloading = false;
    canFire = true;
}

}

heres my code. Took a few hours of edits. It works for different types of guns. If the gun youre using is automatic and not semi automatic then make sure it includes the word “Auto” in its tag, then it will fire when LMB is held down, not when its clicked. Just set max ammo, ammo, clip ammo, and clip size to whatever you like, but keep rammo (remaining ammo) at 0. I also have a display script if you need it.