I am making a Lerp Coaster that is built in an in pairs loop. The track gets lerped through every part in the table. It works but for some reason there is a pause in between each lerp. I want to make it so it doesn't or at least have minimum pauses between each lerp.
Here is my code
local train = Instance.new("Part")
local folder = script.Parent
local track = folder.Track:GetChildren()
train.Parent = game.Workspace
train.Anchored = true
train.Position = Vector3.new(-2, 0.5, 6.8)
local sortedTrack = table.sort(track, function(a, b). --sorts the table through alphabetical order
return a.Name < b.Name
end)
for i,v in ipairs(track) do. -- actual movement
for x = 0,1,.01 do
wait(-1)
train.CFrame = train.CFrame:Lerp(v.CFrame, x)
if train.Position == v.Position then
print("train arrived now moving to next part")
end
end
end
here is the screen recorded Gyazo of the part Lerping through the track https://gyazo.com/43a20c9c874d25d0d280eb3bd9faeb7c

1 comment
Might be because the loop is still "moving" the part but with barely noticeable movements