Gun script

i am trying to make a gun and i need some help with coding

hears my script so far

#pragma strict
var bullet : Rigidbody;
var power : float = 1500;
var damage : float = 100;
var reloadtime : float = 4;
var magcount : float = 10;
var magbulletcount : float = 21;


function Start () {

}

function Update () {

         if (Input.GetButtonDown("Fire1")){
             var instance: Rigidbody = Instantiate(bullet, transform.position, transform.rotation) as Rigidbody;
             var fwd: Vector3 = transform.TransformDirection(Vector3.forward);
             instance.AddForce(fwd * power);
         
         }

}

as you can see i have got a bullet to instantiate and being able to change the force of the bullet sorted
but i need help with the rest
i want it so when the bullet mag count = 0 then it waits the reload time and the mag count goes down by one and when the mag count = 0 i want it so you carnt shoot anymore im not asking for somebody to finish the script but does anybody know like a tutorial?

You can use a Coroutine.

#pragma strict
var bullet : Rigidbody;
var power : float = 1500;
var damage : float = 100;
var reloadtime : float = 4;
var magsize : int = 21;
var magcount : int = 10;
var bulletcount : int = 0;

function Start () {
         bulletcount = magsize;
}

function Update () {

     if (Input.GetButtonDown("Fire1") && bulletcount > 0) {
         var instance: Rigidbody = Instantiate(bullet, transform.position, transform.rotation) as Rigidbody;
         instance.AddForce(transform.forward * power);
         bulletcount--;
         if (bulletcount == 0) {
             StartCoroutine("Reload");
         }
     }
}

function Reload () {
     yield WaitForSeconds(reloadtime);
     bulletcount = magsize;
}