Weapon not appearing

Hi!

I have made this WeaponSwitch script for my players in my game. When I try to switch weapon, it doesn’t appear. This has just been tested with secondary and primary weapon. There is no problem with the primary but when I switch to secondary, it doesn’t appear. It has the exact same properties as the primary one.

Here is my script:

void Start () {
		primaryWeapon.SetActive(true);
		secondaryWeapon.SetActive(false);
		meeleWeapon.SetActive(false);

		anim = GetComponent<Animator>();
	}

	void Update () {
		if(slot > 1){
			slot = 0;
		}

		if(slot < 0) {
			slot = 1;
		}

		if(Input.GetAxis("Mouse ScrollWheel") < 0){
			slot -= 1;
		}

		if(Input.GetAxis("Mouse ScrollWheel") > 0){
			slot += 1;
		}

		if(slot == 0){
			primaryWeapon.SetActive(true);
			secondaryWeapon.SetActive(false);
			meeleWeapon.SetActive(false);
		}

		if(slot == 1){
			primaryWeapon.SetActive(false);
			secondaryWeapon.SetActive(true);
			meeleWeapon.SetActive(false);
		}

		if(slot == 2){
			primaryWeapon.SetActive(false);
			secondaryWeapon.SetActive(false);
			meeleWeapon.SetActive(true);
		}
	}

If you know what the problem is, please tell me. Thanks.

Try this (untested)

private float comulatedWheel = 0.0f;

void Update () {
float wheel = Input.GetAxis("Mouse Scrollwheel");

comulatedWheel += wheel * 0.1f;
if (Mathf.Abs(comulatedWheel) > 1.0f) {
slot += Mathf.Sign(comulatedWheel);
comulatedWheel = 0;
}

if(slot == 0){
         primaryWeapon.SetActive(true);
         secondaryWeapon.SetActive(false);
         meeleWeapon.SetActive(false);
       }
 
       else if(slot == 1){
         primaryWeapon.SetActive(false);
         secondaryWeapon.SetActive(true);
         meeleWeapon.SetActive(false);
       }
 
       else if(slot == 2){
         primaryWeapon.SetActive(false);
         secondaryWeapon.SetActive(false);
         meeleWeapon.SetActive(true);
       }

else {
slot = 0;
}
}