I am working on a train system that lerp
s 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 lerp
ing 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.