Trying to calculate velocity

Im currently working on a game trying to imitate the feeling of vr without vr, so anyway I need to calculate the velocity of the left hand and the right hand this is my current code:

local mp = 13

function getDis(v1,v2)
	local x1 = v1.X
	local y1 = v1.Y
	local z1 = v1.Z
	
	local x2 = v2.X
	local y2 = v2.Y
	local z2 = v2.Z
	
	local x = 0
	local y = 0
	local z = 0
	
	if x1 > x2 then
		x = x1 - x2
	else
		x = x2 - x1
	end
	
	if y1 > y2 then
		y = y1 - y2
	else
		y = y2 - y1
	end
	
	if z1 > z2 then
		z = z1 - z2
	else
		z = z2 - z1
	end
	
	return Vector3.new(x * mp,y * mp,z * mp)
end

“mp” is just the value that the vectors get multiplied by, however sometimes this causes the object to go in the complete opposite direction. Any help would be very appreciated.

And because I’m using :SetPrimaryPartCFrame the actual velocity property isn’t active which is why this entire issue occurred.

This may not be the answer you are looking for, but if you are trying to simulate physics it would make more sense to move the hands with Roblox physics rather than CFrame. That way you won’t need to code physics at all.

Easiest way to achieve this is with legacy BodyMovers.
For position, BodyPosition
For rotation, use BodyGyro’s CFrame property.

If you still want to calculate velocity, the formula is position displacement over time.

local velocity = (position1 - position2).Magnitude / delta
-- delta is the time between getting position1 & position2

Can’t you use the parts magnitude?