Solved: deactivating objects not working

I’ve searched the forums for a solution, but none that I found seem to apply or work for my situation. Anyways, I have two different gun objects, that are both parented to the Main Camera object under the FPS Controller form the Standard Assets. Both objects are placed in the scene where they would be if the player was carrying them, and both are active. I am trying to get them to deactivate when that current weapon is not selected, and then activate when it is selected. Attached to each each object is this script(with the necessary changes to the weapon variable and the tag, of course):

function Update(){
	if (!(playerInit.playerWeapon == 1))
	{
		gameObject.active = false;
	}
	else
	{
		gameObject.active = true;
	}	
}

playerInit is a script attached to the player object. playerWeapon is a public static variable that is created and initialized in that script. This is the variable that controls the currently selected weapon(0 for pistol, 1 for smg). The code above is supposed to check if the variable is set to 1(value for the smg), and then activate/deactivate it based on this check. This script is attached to the smg object. There is a similar one attached to the handgun object, but the value is checked for 0. Both objects are set to active in the inspector. I am not sure why this is not working; from what I’ve read about the subject it should. The two gun objects are prefabs, if that matters. Can someone help me with this? I’d really appreciate it. Thanks for your time!!!

first off, “!=” would be “not equals”, as in:

if (playerInit.playerWeapon != 1)

I would also make the script more reusable, to have the same one for each weapon… An [enum][1] is perfect for this:

enum WeaponType{ Pistol, SMG, Laser }

var myType : WeaponType;

function Update(){
    if (playerInit.playerWeapon == myType)
       renderer.enabled = true;
    else
       renderer.enabled = false; 
}

Note that with an enum, each key has a default int value (Pistol = 0, SMG = 1, etc…), so this example should work as intended, plus it’s much easier to add more weapon types this way, without altering too much, and the same script will work for each weapon… (I think renderer.enabled is sufficient here, as the code may not be running on the object itself once it is disabled… assuming you just want to show/hide the appropriate mesh, this should suffice)
[1]: http://msdn.microsoft.com/en-us/library/sbbt4032(v=vs.80).aspx