Linear velocity to miles per hour

Im trying to figure out how to convert linear velocity to miles per hour but I can’t find anything online about this. Is linear velocity just studs per second or how does it work?

TL;DR:

local mph = part.AssemblyLinearVelocity.Magnitude * 0.626342182

Yes, linear velocity is measured as studs/second. Let’s work through the conversion:

  • 1 stud = 0.28 meters. We can figure this out by going to Game Settings and looking at Gravity. Set Gravity to 1, and Roblox will note that this is equivalent to 0.28 m/s^2. So, this is our reference point.
  • 1 meter = 3.28084 feet. So we can multiply by 3.28084 to go from meters to feet.
  • There are 5280 feet in a mile. So, 1 mile = 5280 feet. We will use this to convert feet to miles (and thus feet/s to miles/s).
  • Then multiply by 3600 (60*60) to get to MPH, as there’s 3600 seconds in an hour).

So, if we were to work this through line-by-line in code, it would look like:

local studsPerSecond = part.AssemblyLinearVelocity.Magnitude
local metersPerSecond = studsPerSecond * 0.28
local feetPerSecond = metersPerSecond * 3.28084
local milesPerSecond = feetPerSecond / 5280
local mph = milesPerSecond * 60 * 60

Of course, we can simplify this all down to one number, since we’re just scaling everything line-by-line.

So, our magic number is going to be 0.28 * 3.28084 / 5280 * 60 * 60 = 0.626342182. Thus, we can just multiply our studsPerSecond by this number to get to miles per hour:

local STUDS_SEC_TO_MPH = 0.626342182

local studsPerSecond = part.AssemblyLinearVelocity.Magnitude
local mph = studsPerSecond * STUDS_SEC_TO_MPH
12 Likes

You can also check the documentation to find unit conversions between Roblox units and metric units:
Roblox Units | Documentation - Roblox Creator Hub

(1 stud is listed as 28cm, so your original reference point was accurate)

3 Likes

The only additive I’d say to this is it depends on what the OP is actually doing with this conversion. If strictly talking about the character, then yes this would be the most accurate calculations of it all.

If the OP is talking about a vehicle or other object in motion that they have created then they’d wanna adapt the calculation to the scale of the vehicle.

All of that said. I personally prefer to use the “1 foot = 1 stud” scale which would change it all to

LinearVelocityAssmebly * .6818181 (or .682)
to change from 1 foot per second to miles per hour.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.