Weapon Selector

Alright i have two different weapons at the moment, a single shot, and a triple shot. Now i have the 3-way shot set as a power-up. So if i get to the power-up, i got to shoot 3 bullets at once, over just one. That part works, but I want it so that after i get the power-up, it will automatically make it so i can switch from single shot to triple shot at the push of a button (1 and 2). Here is how i thought about doing it, but it doesn't seem to work.

 function Update () {
if(Input.GetKeyDown("1")) {
var weapon = 1;

if (weapon == 1 ) {

The actual code is quite a bit longer so i only grabbed the parts that pretain to it. Also, the if (weapon == 1) part IS in the update function. Now the actual problem with this script is that when i press 1, it seems it does nothing, but if i repeatedly press 1 and fire at the same time, i will randomly shoot 3 amidst lots of single shots. So more or less i want it so it is a toggle. I want it so when weapon is set to 1 it will stay 1 till i click something different.

Lastly, after the checking what weapon is part i have it making the bullets, adding force, and adding random rotation to make them spread. I also have taken a look at the FPS tutorial but it makes no sense to me how they did it.

You set your weapon variable to 1 by pressing "1" (and set to 2 when pressing 2). So far so good.

Now you could check whether the player is firing any weapon and inside this if-statement you would create the two scenarios for 1-shot vs triple-shot. That's pretty much what you have there (just reversed), but if you keep that clean and simple, it should work.

Something like this would be in your update function alongside the if-statements which select your weapon (which you already have).

if(Input.GetButtonDown("Fire1")) {

    	if (weapon == 1) {
    	  //do weapon 1 stuff
    	if (weapon == 2) {
    	  //do weapon 2 stuff


You could also combine conditions for your if-statement like such:

if (Input.GetButtonDown("Fire1") && weapon == 1) {
   //do weapon 1 stuff here

edit/ It's hard to tell from what your lines of code, but it sounds like you got some if-statements mixed up so that you only shoot 3 bullets when you hit the switch-button and the fire-button at the same time. This should be solved with the above example.