need help with my gun script

when i try to fire a bullet i it goes backwards here is the script

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

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

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

Quaternion.identity);

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

} }

can anyone please help me??

Your bullet prefab is possibly facing backwards. Either rotate the prefab in the editor, or reverse the force you’re applying…

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