[HELP] Is there a way to get a players forward velocity. (No matter what the angle)

Hi Guys.

Im looking for a way to get the Local Players forward velocity returned as one number instead of a vector. ( So the box in the video will only move up and down )
Is this possible? I had a play with this code below and the video below was the result. Any Suggestions??

function draw_HUD()

	-- Everything will be parented to this.

	hud_frame = vgui.Create("DPanel")
	hud_frame:SetSize( ScrW(), ScrH() )
	hud_frame.Think = function()

	vel_x = LocalPlayer():GetVelocity().x
	vel_y = LocalPlayer():GetVelocity().y
	vel_z = LocalPlayer():GetVelocity().z

	hud_frame:SetPos( 0 + vel_x , 0 + vel_y )

	hud_frame.Paint = function() end

	test_box = vgui.Create("DPanel", hud_frame)
	test_box:SetSize( 300, 300 )
	test_box:SetPos( (ScrW()/2) - 150, (ScrH()/2) - 150 )
	test_box.Paint = function(self)

		draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 255 ) )



Unless you only want the forwards velocity (not sideways), but I don’t think you want that even though your title suggests it, then this is the way to go:
[lua]local speed = LocalPlayer():GetVelocity():Length()[/lua]


[editline]1 September 2014[/editline]

fucking ninja’d


Thanks Guys… Got what i needed.

Although Tommy228 contacted me suggesting i tie moving the box around to player movement binds which would also suit. However i can use this variable to keep the movement animations in sync.