Tried fixing this old Double Jump code for pointshop... Any ideas? What went wrong?

So I tried fixing the code for this one but it says “Jump” isn’t a real value/is nill/null?

Here it is, I tried changing the values for x but nothing, can someone help or fix this up for me?


ITEM.Name = 'Double Jump Test'
ITEM.Price = 600
ITEM.Model = 'models/Items/battery.mdl'
ITEM.NoPreview = false

function ITEM:OnEquip(ply, modifications)
end 
	
function ITEM:Think(ply)
	if  !IsValid( ply ) || !ply:Alive() then return end

	if ply:IsOnGround() then
		ply.Jumps=0
	end

	if ply:KeyPressed(IN_JUMP) then 

		ply.Jumps = (Jumps + 1)

		if ply.Jumps==2 then
			local ang = ply:GetAngles()
			local forward, right = ang:Forward(), ang:Right()

			local vel = -ply:GetVelocity() -- Nullify current velocity
			vel = vel + Vector(0, 0, 300) -- Add vertical force

			local spd = ply:GetMaxSpeed()

			if ply:KeyDown(IN_FORWARD) then
				vel = vel + forward * spd
			elseif ply:KeyDown(IN_BACK) then
				vel = vel - forward * spd
			end

			if ply:KeyDown(IN_MOVERIGHT) then
				vel = vel + right * spd
			elseif ply:KeyDown(IN_MOVELEFT) then
				vel = vel - right * spd
			end

			ply:SetVelocity(vel)
		end
	end
end 

function ITEM:OnHolster(ply)
end

Change all instances of ply.Jumps to Jumps.

It seemed to work, however in game it does nothing. I feel like when jump/space is pressed a second time there is no added boost, can i change it?

I remember looking for a Double Jump thing ages ago and found code _Kilburn wrote a few years back, which still works fine. Looking at it, it’s pretty much the same as what you have here, but on a KeyPress hook. Maybe that’s the issue?



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)


-snip-

I will try this in a bit and let you know

[editline]25th June 2014[/editline]

Actually how would I add this to replace the current file to test it out?