How to wait when reloading?

I have some code that reloads when you press r but then you can start firing again. How could you put a little delay after you click r? Not meaning a animation though…

Try adding something similar to this to your code:

var reloading : boolean = false;

function Update() {
   if(Input.GetButton("Fire1") && !reloading) {
       //shooting code
   }

   if(Input.GetKey(KeyCode.R) && !reloading) {
       Reload();
   }
}

function Reload() {
    reloading = true;
    //reload code
    yield WaitForSeconds(2); //how ever long you want the delay to be in seconds
    reloading = false;
}