hud painting help

I am trying to do this in GM:HUDPaint -
[lua]if LocalPlayer():InVehicle() then
if updatedTime == nil then
local updatedTime = CurTime()
end
if oldLoc == nil then
local oldLoc = LocalPlayer():GetPos()
end
draw.DrawText( tostring( math.floor((LocalPlayer():Distance( oldLoc )*63360)/(math.abs( CurTime() - updatedTime() )*3600)) )…" MPH", “DarkRPHUD2”, ScrW()/2, ScrH()/2, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER )
local updatedTime = CurTime()
local oldLoc = LocalPlayer:GetPos()
end[/lua]

edit: fixed a few problems i noticed, but now it is telling me it can’t index Distance as an error

[lua][ERROR] gamemodes/darkrp/gamemode/client/hud.lua:345: attempt to call method ‘Distance’ (a nil value)

  1. unknown - gamemodes/darkrp/gamemode/client/hud.lua:345
    [/lua]

Instead of


if updatedTime == nil then
	local updatedTime = CurTime()
end

You should have


updatedTime = updatedTime or CurTime( )

By declaring local inside that if condtion, it reverts back to nil after you leave the block.

After drawing it, you should change it from


local updatedTime = CurTime( )

To


updatedTime = CurTime( )

For the same reason.

The next problem is


(math.abs( CurTime() - updatedTime() )*3600

updatedTime is not a function - get rid of the () after it.

I suspect that the code isn’t running, because this would error as it is currently.

Also, Player:Distance isn’t a function - Vector:Distance is, so you’d need to do LocalPlayer( ):GetPos( ):Distance( x )

ok, thank you. Now i just have to fix the speedometer because apparently i am going 5000+ mph at full speed in an airboat

found calculation error, threat neutralized.