How to reset a variable when activated

Im making a FPS and I have several guns. i set it so when the guns are equipped, there is a variable that is deactivated/activated at certain times so the player cant shoot while reloading, or equipping.

I made the gun start where it cant shoot, because the fraction of a second difference between the gun being activated and the animation playing allows the player to shoot, and then switch guns, so then the gun he switched to will start shooting without being equipped. The varibale "abletoshoot" starting at 0 makes the player unable to do this.

The problem is that this only works the first time the weapon is equipped, because "abletoshoot" is not converted back to 0. I was wondering if there is a function thast I can call so when the weapon is activated, set it to 0, or deactivated, set it to 0.

is there such a function to call? activated or deactivated, or possibly something I can use to reset the variable when the weapons are activated or deactivated.

Just happened across this question and can't resist answering. I like easy questions. ;)

Put a Boolean in the script that is flipped back and forth from true to false and back again. Like ableToShoot = true/false That seems more straightforward than setting a number.

This post (below) helped me out quite a bit back a while ago. It should show how to set up bools.