Velocity of a Player

I want to make a HUD with velocity of the Player.

But in Gmod Wiki I cant Find anything which Gets the Player Speed(for Deathrun).

Is there anything or not?

If yes pls tell me

Player:GetAbsVelocity. Returns a vector, so you’ll have to take the length

[ERROR] lua/includes/extensions/math.lua:160: bad argument #2 to ‘__add’ (Vector expected, got number)

  1. __add - [C]:-1
  2. Round - lua/includes/extensions/math.lua:160
    3. RoundedBox - lua/includes/modules/draw.lua:189
    4. v - lua/test.lua:30
    5. unknown - lua/includes/modules/hook.lua:84

What did I wrong?

[editline]11th January 2017[/editline]

Ok I found the Solution: GetVelocity():Length2D()

[editline]11th January 2017[/editline]

New Problem: There is not showing 400…
It is showing 400.00516946549874984

Use Length and not Length2D since it will not take into account the z velocity. Also, math.floor the result.

What’s the point of using math.floor?

It will round the number down to the nearest whole number, basically getting rid of that long string of decimals at the end.

math.floor works, but if he wanted to be as accurate as he could, math.Round would be more precise.

It’s standard practice to floor speeds in programming and physics to my knowledge. Think of it like a float to int casting.