I’ve written a script to animate a lootbox, the code runs something like this:
function SpinObjects:Move(distToMove)
self.Position = self.Position + distToMove
if self.Position > END_POSITION then
self:Destroy()
SpinObjects.new(OutfitDataManager.GetRandomOutfitWithRarity(3), MostRecent.Position - (PADDING + FRAME_SIZE))
else
self:SetFramePosition()
end
end
function SpinObjects:SetFramePosition()
self.Frame.Position = UDim2.new(self.Position, 0, 0.5, 0)
end
local heartbeatBind = RunService.Heartbeat:Connect(function(dt)
local distToMove = dt * SPEED
for object, _ in pairs(LiveObjects)do
object:Move(distToMove)
end
end)
end)
So its pretty simple, it just moves everything along every heartbeat. SPEED is defined as the speed it should be travelling every second, so doing dt * SPEED is legit, no need for a /60 in there.
However, I get this stutter which makes it hideous
I thought at first maybe the animation hadn’t finished before the next heartbeat, but that wasn’t the case. Any help would be much appreciated