i have tried to make a cannon, every thing works fine except the fuse, meaning it will fire but won't have the 2 second delay, what am i doing wrong

#pragma strict

 var CannonBall : GameObject;
 var Fuse : float = 2.0;
 var CannonShot : AudioClip;
 
 function OnMouseDown()
 {
         {    if(Fuse > 0)
             Fuse -= Time.deltaTime;
     }
         {    if(Fuse <= 0);
{ 
GetComponent.<AudioSource>().PlayOneShot(CannonShot)

var instance : GameObject = Instantiate(CannonBall,Vector3(299.19,26.5,166.15),
transform.rotation);
         }
     }
 }

Sorry, but i’m very new to this, how
would i go about making it so i don’t
have to hold the mouse down on it for
it to trigger, example, light fuse,
walk away, 2 seconds later it goes
off.

We all started somewhere :slight_smile:

#pragma strict
   
var CannonBall : GameObject;
var fuseTime : float = 2.0;
var fuse : float;
var cannonShot : AudioClip;
var firing : boolean = false;   

// When we start the game, we'd like to initialize the fuse to the defined fuseTime.
// So if you want to change the fuseTime, you only need to change it in one place!   
function Start(){
    fuse = fuseTime;
}   
   
function Update(){
    // If the mouse button is pressed, then we are saying that the cannon is currently firing.
    if(Input.GetMouseButtonDown(0)){
        firing = true;
    }
    
    // If the cannon is firing, then we want the fuse to start ticking down.
    if(firing){
        Fuse -= Time.deltaTime;
    }
    
    if(fuse <= 0){
        GetComponent.<AudioSource>().PlayOneShot(cannonShot)
        var instance : GameObject = Instantiate(CannonBall,Vector3(299.19,26.5,166.15), transform.rotation);
        // Let's reset the fuse!
        fuse = fuseTime;
        // Let's say the cannon is no longer firing. In other words, you need to press the button again to fire again
        firing = false;
    }
}