How to run code on ToolGun fire?

How can i run a code when Tool Gun has ben fired or being fired?

a friend told me i could do

[lua]
ply:KeyPressed(IN_ATTACK) and ply:GetActiveWeapon():GetClass() == “gmod_toolgun”
[/lua]

but i don’t like to add it in GM:Think() so is there another way? :smiley:

CanTool hook will do exactly that.

Thanks! :smiley: