Weapon shooting?JS

Hi all. Need help getting this script together. In game i have like 20 weapons.So i don’t want to make for each simple shoot script.Can i do something with {array} here’s what i tried .I just don’t know how to do it.Any help?

//I'll delete BulletPrefab when i fix the script
var BulletPrefab:Transform;
var force : float = 2000;
var Weapons = new GameObject[0];
var Bullets = new GameObject[0];

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

GameObject.Find("spawnPoint").transform.position, 

GameObject.Find("Gun").transform.rotation);

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

}
}

-Ty

is this script attached to all weapons ?

Maybe use an enum for the weapon types and go from there, if you don’t mind the code being kinda lengthy.
For the shooting portion of the code, try InvokeRepeating. You can make the different guns fire slower, faster, have a delay before shooting, etc.

You should implement strategy pattern. This let you change the player weapon behavior easily.