Automatic fire in weapons

Im currently away from home and cant test this, but im asking anyway in case i have to ask anyway later.(on mobile at school.) i’ve been wondering about how to do an automatic weapon, and i’m asking will the following work to make it full auto? Script isn’t precise.

Var isitshooting : boolean = false;
Var firerate : float = 0.1;                   // makes the gun shoot ten times per second

Function fire(){
//stuff that makes it shoot
//i'll put here later
//this function is the one that shoots
}

Function Start() {
invokerepeating("checkiffiring",0,firerate);
}

Function checkiffiring() {

If(isitshooting == true) {
     fire();
}
}

Function on.keydown(mouse0) () {          //pressing the first mouse button, pretend it's correct.
     isitfiring = true;
}

Function on.keyup(mouse0) () {              // releasing the mouse button
     isitfiring = false;
}

Again, im on mobile so The script has syntax errors but the jist of the script is what im wondering about

There is a completed script for this here:

www.unity3dmax.comxa.com

there is also a bunch of other useful stuff!