I Need Help with a Double Jump Code

So i have this double jump code that was from a thread post but idk how to edit it to my needs. My needs: i want it to be activated when u press space a second time, (pressing space once makes you jump once but when you press it a second time you jump again. like the scout from tf2), i want it for both teams, and PLEASE tell me where to put the code (its a prophunt server).

hook.Add(“KeyPress”, “DoubleJump”, function(pl, k)
if not pl or not pl:IsValid() or k~=2 then
return
end

if not pl.Jumps or pl:IsOnGround() then
	pl.Jumps=0
end

if pl.Jumps==2 then return end

pl.Jumps = pl.Jumps + 1
if pl.Jumps==2 then
	local ang = pl:GetAngles()
	local forward, right = ang:Forward(), ang:Right()
	
	local vel = -1 * pl:GetVelocity() -- Nullify current velocity
	vel = vel + Vector(0, 0, 300) -- Add vertical force
	
	local spd = pl:GetMaxSpeed()
	
	if pl:KeyDown(IN_FORWARD) then
		vel = vel + forward * spd
	elseif pl:KeyDown(IN_BACK) then
		vel = vel - forward * spd
	end
	
	if pl:KeyDown(IN_MOVERIGHT) then
		vel = vel + right * spd
	elseif pl:KeyDown(IN_MOVELEFT) then
		vel = vel - right * spd
	end
	
	pl:SetVelocity(vel)
end

end)

Use lua tags.

Try something like this:

[lua]
local JUMP_HEIGHT = 300

hook.Add(“OnPlayerHitGround”, “DoubleJumpHitGround”, function(ply)
if not IsValid(ply) or not ply:Alive() then return end
ply.DoubleJumped = false
end

hook.Add(“KeyPress”, “DoubleJumpKeyPress”, function(ply, key)
if not key == IN_JUMP or not IsValid(ply) or ply.DoubleJumped or not ply:IsOnGround() or not ply:Alive() then return end

timer.Simple(0, function()
	if IsValid(ply) and ply:Alive() and not ply:IsOnGround() then
		local vel = ply:GetVelocity()
		vel.z = JUMP_HEIGHT
		ply:SetVelocity(vel)
		ply.DoubleJumped = true
	end
end	

end[/lua]

where do i put it though

If it goes in the player classes then it doesnt work because error in line hook.Add(“OnPlayerHitGround”, “DoubleJumpHitGround”, function(ply)