Sipmle script. Rate of fire.

This script doesn’t work. Plz. help me. :dance:
Works - dmg ,but rate of fire doesn’t work.

local function HookEntityTakeDamage(victim, dmg)
	if IsValid(dmg:GetAttacker()) and dmg:GetAttacker():IsPlayer() then
		local weapon = dmg:GetInflictor()
		if IsValid(weapon) and weapon.Primary and weapon.Primary.Delay then
			weapon.Primary.Delay = weapon.Primary.Delay/2

hook.Add("EntityTakeDamage", "hook_name", HookEntityTakeDamage)

That’s because that’s a damage scale hook

And what it is necessary a hook?

Well when do you want to change the rate of fire?

Yes I want to change rate of fire.
What hook to use?
Write please

Should be
local weapon = dmg:GetAttacker():GetActiveWeapon()

Oh, yes as I forgot about the weapon?
It has to work!
Thanks, is my oversight!

Oh, yes it works!

[editline]23rd March 2015[/editline]

Thx everybody.

[editline]23rd March 2015[/editline]

Thx everybody.