Does anyone know how I can disable shooting for a weapon but for aiming to still be enabled?

(For example, i want a Melee weapon called grapple blade to not be able to use the blade against players but still be able to grapple around and stuff) Does anyone know how to do that please help!!!