How can I tell how fast an object is moving?

Yes this post has been made many times, but for each post it seems to be a different solution.
People have said use AssemblyAngularVelocity or AssemblyLinearVelocity but those values never seem to change (Idk if its just me but they seem not to be).

People have said to just check the parts current po, wait a second and then get the new one and find the distance, but I cant really wait cause it’ll mess up the rest of my code.

So how can I do this?

1 Like

you can try using .Velocity.Magnitude

3 Likes

Ok, if this is the only option ill go with it due to this being deprecated

What do you need to get the velocity for? Are you displaying the speed or something else?
BasePart.AssemblyLinearVelocity returns a Vector3, BasePart.AssemblyLinearVelocity.Magnitude gives you the speed in any direction.

why is the part’s AssemblyLinearVelocity not changing?, is the part being moved with cframes? It should change if its being moved physically

1 Like

Yup thats it exactly!
Theres a character limit lol

Im moving it with linear velocity, but sometimes it just doesnt update

If you have some sort of update loop, you can save the velocity to a variable at the top of the script with BasePart.AssemblyLinearVelocity.Magnitude or pass it in directly to wherever you are displaying it. If you don’t, look at RunService and try using this update loop:

local RS = game:GetService("RunService")

RS.RenderStepped:Connect(function()

end)

I’d like to use said method but what about this problem?

When you change the AssemblyLinearVelocity does the part in the viewport move? If you are changing the velocity at set intervals or something else, AssemblyLinearVelocity should update. Are you setting AssemblyLinearVelocity directly or using ::ApplyImpulse?

He’s using the LinearVelocity contraint, not directly setting the AssemblyLinearVelocity

2 Likes

odd, i tried moving a part with the contraint and the AssemblyLinearVelocity does update, how exactly are you changing the contraint?

Can you send a video of the problem? What do you mean by it doesn’t update? Does the AssemblyLinearVelocity in the properties window not match the actual result?

Basically what happens is sometimes the property, is just 0,0,0.
It doesnt change, it just stays that way.

That happens a lot. Usually unselecting the part or selecting something else gets AssemblyLinearVelocity to update properly.
However, getting AssemblyLinearVelocity using BasePart.AssemblyLinearVelocity returns the newest values.

1 Like

Ok your idea works! Yay!!!
Although it is like a decimal value, do you know a formula I could use to make it more like MPH?

Look into string.format . string | Documentation - Roblox Creator Hub

local speed = 20
local fspeed = string.format("%iMPH",speed)

This just formats the actual speed to the nearest integer and adds “MPH” to the end.

1 Like

If you want to round up to the next integer, you can wrap speed with math.ceil, or math.floor to round down.