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?