weapon system script

hi there, i am trying to script a weapon system were i have different weapons and can switch between them. i added ammo too. but every time i want to test it the programm automaticly changes into the pause mode and i can't restart -.-

please help me!

here is my script:

var projectil1:Transform; //Prefab for the projectil of weapon 1 var projectil2:Transform; //Prefab for the projectil of weapon 2 var power1 = 2000; var power2 = 2000; var FireButton = "f"; //Keyboard key used to shoot var ammo_typ1 = 20; //Ammo for weapon 1 var ammo_typ2 = 3; //Ammo for weapon 2 var weapon = 1; //wich weapon is in use var TotalWeaponNumbers = 2; //how many weapons exists in the game

function Update () { print (weapon);

//change weapon: if(Input.GetKeyDown("e")) { if(weapon TotalWeaponNumbers) {weapon = 1;} if(weapon < 1) {weapon = TotalWeaponNumbers;}

//weapons: //weapon 1 if(Input.GetKeyDown(FireButton)) { if(weapon == 1) { if(ammo_typ1>0){ var bullit1 = Instantiate(projectil1, GameObject.Find("spawnpoint").transform.position, Quaternion.identity); bullit1.rigidbody.AddForce(transform.forward*power1); ammo_typ1 -=1; }}}

//weapon 2
if(weapon ==2)
var bullit2 = Instantiate(projectil, GameObject.Find("spawnpoint").transform.position, Quaternion.identity);
ammo_typ2 -=1;

The pausing is probably because you're getting an error when you try to play, and Unity is pausing. Check if you have "Error Pause on by clicking the bottom of the Unity window to open the console, then seeing if Error Pause is highlighted.

If there is an error, then editing your question to include the specific error message will make it a lot easier for people to help you fix it.