Choppy KeyframeSequence when playing it

I’m trying to make a game that lets you view animations with just the id

But the animation is choppy (see the arms)

This is my script

local function playKeyframes(rig : Model, keyframes : KeyframeSequence)
	local offset = {}

	local function getMotor6DFromPose(pose : Pose) : Motor6D		
		for i, v in rig:GetDescendants() do
			if v:IsA("Motor6D") and v.Part1.Name == pose.Name and v.Part0.Name == pose.Parent.Name then -- and v.Part0.Name == poseParentName
				return v
			end
		end
	end

	local children : {Keyframe}? = keyframes:GetKeyframes()

	table.sort(children, function(a, b)
		return a.Time < b.Time
	end)

	for nth, keyframe in children do
		local time = 0

		if children[nth + 1] then
			time = children[nth + 1].Time - keyframe.Time
		end

		for _, pose : Pose? in keyframe:GetDescendants() do
			local limb = getMotor6DFromPose(pose)

			if limb and pose.CFrame ~= CFrame.new() then
				offset[limb] = offset[limb] or limb.C0

				local EasingStyle, EasingDirection = 
					Enum.EasingStyle[pose.EasingStyle.Name], 
					Enum.EasingDirection[pose.EasingDirection.Name]

				local ticked = tick()

				spawn(function()
					--transform
					while tick() - ticked < time do
						local cframe = limb.C0

						-- n / time
						limb.C0 = cframe:Lerp(offset[limb] * pose.CFrame, TweenService:GetValue((tick() - ticked) / time, EasingStyle, EasingDirection))
						RunService.PreSimulation:Wait()	
					end

					limb.C0 = offset[limb] * pose.CFrame
				end)
			end
		end

		wait(time)
	end
end

How to fix?

try setting your graphic quality in the menu higher to fix it?

1 Like

No that’s not the problem

When I use this module https://devforum.roblox.com/t/keyframesequence-reader-better-loadanimation/3103516 it works perfectly it is smooth

Why is mine not smooth???

1 Like

why not just use load animation instead tho?

1 Like

Because I cannot use a key frame sequence for load animation

3 Likes

Idk. I had some problems with the smoothness. I’m pretty sure that’s not the problem, but try using deltaTime from the RunService instead of tick() - lastTick
Changed:
(Oh, I don’t think I noticed the “<time”.)

1 Like

How do you think I could do this?

1 Like

Oh yeah I forgot about this also yes I will try this when I am on my laptop thanks

Wat. Just: RunService.RenderStepped:Connect(function(DELTATIME)

Oh I’m dumb lol Ok I will try this when I get home

1 Like