How to properly move "train carriages" behind the train?

I am working on a train system that lerps the CFrame of the train, including all of the “train carriages” behind it to move. However, over time, some of the train carriages are out of sync (When the train gets near the last tunnel, some of the “train carriages” are slightly going through each other / are slightly separated)

And for those wondering, I am lerping the CFrame of the train, and it’s carriages on the client (So the train moves smoother).

Here is what i’m using to move the train:

local module = {}

function module:Create(initial, target, TIME, part)
	local s = tick()
	repeat
		game:GetService("RunService").Stepped:Wait()
	    part.CFrame = initial:lerp(target, math.min((tick() - s) / TIME, 1))
	until part.CFrame == target
end
return module

If you need more information then let me know.

3 Likes

That’s a nice smooth moving train. As of now, I was trying to make a cargo caravan of trucks but can’t figure out how I’d pull it off.

1 Like