Say for instance you wanted to begin a CFrame lerp for multiple parts in one go at random times. What would the most resourceful/efficient method be?
I want to use:
local parts = {...};
function lerp()
local a = 0;
repeat
local dt = game:GetService'RunService'.Heartbeat:Wait();
for i = 1, #parts do
a += dt;
parts[i].CFrame += CFrame.new(0, dt * 30, 0);
end
until a >= 1; --each part escalates by 30 studs in approx. 1 second
end
Or would using the event be better?
local a, parts = 0, {...};
game:GetService'RunService'.Heartbeat:Connect(function(dt)
if a <= 0 then return; end;
a -= dt;
for i = 1, #parts do
parts[i].CFrame += CFrame.new(0, dt * 30, 0);
end
end)
function lerp(s)
a += s;
end
If you have a better method feel free to share!