Only switch to weapons already in inventory

Good evening everyone,

I have a weapon switching script that works just fine, but now it’s time to take the next step with it, namely, I don’t want the player to start out with any weapons; they need to buy or find them. So I’ve modified my inventory script to be a weapons inventory, and tried to call it from the weapon switch script, so far, with no success. I think the idea is right, I just haven’t implemented it properly, and am hoping that someone might be able to steer me in the right direction. Thanks, and God bless.

function Start () {
	// Select the first weapon
	SelectWeapon(0);
}

function Update () 
{
	if (Input.GetKeyDown("1"))
	{
	if (WeaponInv.inventoryArray[0] > 0)
	{
		SelectWeapon(0);
	}	
	else if (Input.GetKeyDown("2")) {
	SelectWeapon(1);
	}
	else if (Input.GetKeyDown("0")) {
	SelectWeapon(2);
	}
	}
	}
	
	

function SelectWeapon (index : int) {
	for (var i=0;i<transform.childCount;i++)	{
		// Activate the selected weapon
		if (i == index)
			transform.GetChild(i).gameObject.SetActiveRecursively(true);
		// Deactivate all other weapons
		else
			transform.GetChild(i).gameObject.SetActiveRecursively(false);
	}
}

(Note: only the first weapon is attached to the Inventory right now, as I’m just trying proof of concept at the moment.)

Put a script on each weapon with a weapon locked variable and set it to locked or unlocked either by script when picking up the weapon or in the inspector , then when swapping weapons in function SelectWeapon just check with GetComponentsInChildren() if it’s locked or not, like here