Switch Weapon Script Not taking effect HELP!!

Guys i trying to make a script of switch of Weapon, but not are taking effect :confused: Here the script:

public var PrimaryWeapon : GameObject;

public var SecondaryWeapon : GameObject;

function Update () {

//if(Input.GetAxis ("Mouse ScrollWheel") > 0){ //Frente
if(Input.GetKeyDown ("1")){
PrimaryWeapon.active = true;
SecondaryWeapon.active = false;

//if(Input.GetAxis ("Mouse ScrollWheel") < 0){ //Tras
if(Input.GetKeyDown ("2")){
SecondaryWeapon.active = true;
PrimaryWeapon.active = false;


What i change for the script work? :confused: thanks.

I suppose that in Hierarchy you dragged the correct GameObjects to those variables (that is the GOs that you have inside the scene, and not a plain prefab from your Project), so it could be possible that your weapons aren’t a single gameObject but contain children for the meshes/bones, so you can try to use SetActiveRecursively() instead of setting active only on the root objects (because of course it only acts on the root object itself and not on its children).

This seems to be a bug. You probably attached your script to the camera. Attach it to some game object and it will work.