Disable Damage Raycast?

Hey guys. First time posting a question here. I’m pretty new at Unity and have been learning using YouTube and other tutorials.

At the moment, I have a raycast script running to hit enemies when shooting my handgun, and it also serves to pick up items with an Action Key (E)

However, even when I don’t have the gun equip, they raycast deals damage to the enemy. Is there a way to disable it? Should I do this in the enemy script or raycast?

Please help. Thank you!

var EnemyHealth : int = 25;

function DeductPoints (DamageAmount : int) {
    EnemyHealth -= DamageAmount;
}
    function Update () {
        if (EnemyHealth <= 0) {
            Destroy(gameObject);
        }
    }

dont run the damage function if you dont have a gun.