How to move a consistent distance over an exact amount of time with BodyVelocity?

So, I am trying to insert a BodyVelocity into a player’s HumanoidRootPart (while they have walkspeed and jumppower of 0) and move them a set number of studs in a specific amount of time with it. Here is how I insert it.

local boost = script.BodyVelocity:clone()
local distance = 40
local t = .3
boost.Velocity = (direction * distance) / t
boost.Parent = root
boost.DestroyAfterTime.Disabled = false
wait(t)

The reason the distance and time it takes to go that distance is so important is because I need to calculate the precise CFrame of the player’s HumanoidRootPart at the exact moment they stop. During testing, the CFrame is usually being calculated too early because they BodyVelocity must continue moving the player even after the designated time has elapsed via wait(t).

Any suggestions for how to make them stop on a dime would be appreciated.

Simple. Don’t use BodyVelocity.

I almost always tend to not use BodyVelocity because of it’s inability to be reliable. It is also legacy, meaning it has been superseeded. I reccomend you CFrame or Tween the Character instead.

However, if you still want to use BodyVelocity, you can anchor the player quickly then set the AssemblyLinearVelocity to 0. That should stop the Character from moving instantly.

Using a tween or CFrame won’t take collisions into account though, right? I want physics to still affect the player.