Destroying Instantiated Object, and Object Position is Off?

I’m working on destroying a bullet 3 seconds after it’s created, and making the bullet appear at the same position of the barrel. The bullet is created, has the same rotation, and accelerates. It just goes up and to the right of where the barrel actually is. Also, for some reason, I can’t seem to destroy the projectile, which is a rigidbody. Can anybody help?

function Fire() {

	var projectile = Instantiate(bullet, barrel.position, barrel.rotation);
	
	projectile.rigidbody.AddForce(transform.forward * speed);
	
	bullets++;
	
	Destroy(transform, 3);

}

Destroy(bullet);

That didn’t work either. He’s the whole script, as that fragment might not be enough…

var bullet : GameObject;
var barrel : Transform;
var speed = 1000;
var bullets = 0;

function Update() {

    if(Input.GetButtonDown("Fire1")){
    Fire();
    CancelInvoke("Fire");
     
     }
     
     if(Input.GetButton("Fire1")  !IsInvoking("Fire"))  
        {  
           Invoke("Fire",0.1);  
        }  
     if(Input.GetButtonUp("Fire1"))  
        {  
         	CancelInvoke("Fire");  
        }  
}
   
   
function Fire() {

	var projectile = Instantiate(bullet, barrel.position, barrel.rotation);
	projectile.AddComponent("Rigidbody");
	projectile.rigidbody.mass = 0.1;
	projectile.rigidbody.AddForce(transform.forward * speed);
	
	bullets++;
	
	Destroy(bullet, 3);

}

function OnCollisionEnter(collision: Collision){

Debug.Log("Hi");

}

What object is this script on? You’re adding force in the direction of the object this script is running on. Is that what you’re trying to do? I’m not clear on what exactly you’re trying to achieve.

“I’m working on destroying a bullet 3 seconds after it’s created,”

I figured out the bullet part, now I just need to find out how to destroy the bullet. The variable I named it is “projectile.”

As stated before -

Destroy( theObjectYouWantToDestroy, howLongToWaitBeforeDestroyingIt )