Tweening slowing down at inconsistent speed at certain waypoints

Hello,

I have a traffic system which is basically the server saying to all the clients which car (MeshPart) to spawn with info (Model, Lane, Speed, Waypoint[i] and Waypoint[i+1]).

For optimization, cars outside a certain radius are removed. When a car re-enters the player’s radius it needs to resume its tween from its current position → next waypoint, instead of restarting from Waypoint A → Waypoint B.

It works fine, but when I tried to add curves it started being a bit weird.
The car’s speed seems to slow down during the curve and then go back to normal once it’s done.

This is the tweening function, in short:

function playTween(car, part, tweenTime, trafficSpeed)
	coroutine.wrap(function()

		local distance = (car.Position - part["Part"..i+1].Position).Magnitude
		local tweenTime = distance / trafficSpeed
		
		local TweenInfos = TweenInfo.new(
			tweenTime,
			Enum.EasingStyle.Linear,
			Enum.EasingDirection.InOut,
			0,
			false,
			0
		)

        local finalCFrame = nextPartCFrame * heightCFrame
		local nextPart = part["Part"..i]
		local currentPos = car.Position
		local targetOrientation = nextPart.Orientation
		
		local rotatedCFrame = CFrame.new(currentPos) * CFrame.Angles(
			math.rad(targetOrientation.X),
			math.rad(targetOrientation.Y),
			math.rad(targetOrientation.Z)
		)
		car.CFrame = rotatedCFrame
						
		local MainTween = TweenService:Create(car, TweenInfos, {CFrame = finalCFrame})
		MainTween:Play()	
		MainTween.Completed:Wait()
	end)()
end

Are the distances too short and Roblox cannot calculate such a fast time for the tween?
Thanks

You did put the tweenTime into tween info right?

Yes yes, sorry I forgot to include the TweenInfo part while transcribing my script. As you can see in the video it works.

Honestly, it might really be the short distances. If I’m not wrong, the car’s orientation is changed every time it passes through a green tile, which is a new tween animation each time. The short stutter between the tweens may be the main reason why the car slows down.

If this is the case, you may try to have a new approach by using CFrame:Lerp() instead of tween animations.