Help with gun scripting!?

I started using Unity from yesterday and I have tried to script a gun to fire through java script and the bullets fire out sideways!? any help

Heres the Script

var BulletPrefab:Transform;
var force : float = 6000;

function Update()
{
if(Input.GetButtonDown(“Fire1”))
{
var bullet = Instantiate(BulletPrefab,

GameObject.Find(“spawnPoint”).transform.position,

GameObject.Find(“Gun”).transform.rotation);

bullet.rigidbody.AddForce(transform.forward * force);

}
}

The rotation you’re passing in there is wrong.

You’re calling GameObject.Find, which returns the first object of all your objects that is named ‘whatever’. And it’s very slow.

You want to cache gameObject.Find (note the lowercase G) as local variables for performance reasons.

Either your gun’s forward isn’t forward or you’re Finding the wrong object.