Just Cant Figure It Out

Okay So Im Wondering How Do I Add The Next Weapons Down The Line. I want At Least 5,
I Cant Seem To Think How To Make The Third And So On Show. I thought else if But It Didnt Work.

#pragma strict

var Weapon01 : GameObject;
var Weapon02 : GameObject;
var Weapon03 : GameObject;


function Update () 
	{
		if(Input.GetAxis("Mouse ScrollWheel") > 0)
			{
				SwitchWeapons();
			}


	}
	
function SwitchWeapons()
	{
		if(Weapon01.active == true)
			{
				Weapon01.SetActiveRecursively(false);
			    Weapon02.SetActiveRecursively(true);
			    Weapon03.SetActiveRecursively(false);
			    
			}
			else
			{
				Weapon01.SetActiveRecursively(true);
				Weapon02.SetActiveRecursively(false);
				Weapon03.SetActiveRecursively(false);
			}
			
			
			
			
	}

Place all weapons in array, and works with them via index.

So, if you want “To Make The Third And So On Show”, you should write something like this:

var weaponsArray: GameObject[]; // array of weapons

...
   if(index >= 3)
      weaponsArray[index].SetActiveRecursively(true);
...

cycle through that array and make them all inactive, then active only the one you want.

for(var i=0; i<weaponsArray.length; i++) weaponsArray[i].SetActive(false);
weaponsArray[currentWeapon].SetActive(true);

I’ve Never Used Arrays Before I’m Pretty New And Am Teaching Myself Anyways,
It Lets Me Switch To One Other weapon Then Nothing Else.

#pragma strict

var WeaponsArray : GameObject[];
var CurrentWeapon : int;



function Update () 
	{
		if(Input.GetAxis("Mouse ScrollWheel") > 0)
			{
				
				for(var i=0; i<WeaponsArray.length; i++) WeaponsArray[i].SetActive(false);

                WeaponsArray[CurrentWeapon].SetActive(true);
				
			}


	}

You’re not incrementing CurrentWeapon

You Mean In The Variable Spot?

When you scroll the wheel, in the update function your CurrentWeapon variable needs to change. Otherwise it is always 0, so only that index of the array will be set active.

Here is a sample of a more optimised(untested) code, which does away with the for loop in the Update function(which is never a good idea to have in the first place)

var WeaponsArray : GameObject[];
var CurrentWeapon : int;
var PreviousWeapon : int;
function Start()
{
      CurrentWeapon =0;
     //Deactivate all weapons initially
      for(var i=0; i<WeaponsArray.length; i++) WeaponsArray[i].SetActive(false);
    //Activate the first weapon we want the player to have
     WeaponsArray[CurrentWeapon].SetActive(true);
     

}
function Update () 

    {

        if(Input.GetAxis("Mouse ScrollWheel") > 0)

            {

                
                CurrentWeapon = ((CurrentWeapon + 1) >= WeaponsArray.length) ? WeaponsArray.length-1 : CurrentWeapon + 1;
                WeaponsArray[CurrentWeapon].SetActive(true);

               if(PreviousWeapon != CurrentWeapon)
                   WeaponsArray[PreviousWeapon ].SetActive(false);

                PreviousWeapon = CurrentWeapon;

                

            }
           else
           {
               CurrentWeapon = ((CurrentWeapon - 1) < 0) ? 0 : CurrentWeapon - 1;
               WeaponsArray[CurrentWeapon].SetActive(true);

                if(PreviousWeapon != CurrentWeapon)
                   WeaponsArray[PreviousWeapon ].SetActive(false);

               PreviousWeapon = CurrentWeapon;
           }

 

 

    }