My module refuses to play out the animation and I cannot figure out why. I’m trying to make it play the animation out like a normal one. The things commented out below are the commands I used. I would really be thankful if you helped me. Here’s my code:
local animationConverter = {}
function animationConverter.createDefiningText(animation)
print("recv")
local keyframes = {}
for _, keyframe in pairs(animation:GetChildren()) do
local keyframeTable = {time = keyframe.Time, poses = {}}
local posesTable = keyframeTable.poses
for _, pose in pairs(keyframe:GetDescendants()) do
posesTable[pose.Name] = {bodyPartName = pose.Name, bodyPartCFrame = pose.CFrame}
--table.insert(posesTable, {bodyPartName = pose.Name, bodyPartCFrame = pose.CFrame})
end
local wasInserted = false
for keyframeId, insertedKeyframe in ipairs(keyframes) do
if insertedKeyframe.time < keyframe.Time then
table.insert(keyframes, keyframeId, keyframeTable)
wasInserted = true
break
end
end
if wasInserted == false then
table.insert(keyframes, keyframeTable)
end
end
local actualKeyframes = {}
for keyframeId, keyframe in pairs(keyframes) do
table.insert(actualKeyframes, table.getn(keyframes)-(keyframeId-1), keyframe)
end
return actualKeyframes--keyframes
end
function animationConverter.playAnimation(definingText, character)
local motor6Ds = {}
for _, possibleMotor6D in pairs(character:GetDescendants()) do
if possibleMotor6D:IsA("Motor6D") then
table.insert(motor6Ds, possibleMotor6D)
end
end
for _, motor6D in pairs(motor6Ds) do
local actualPart = motor6D.Part1
local C1 = motor6D.C1
local info = definingText[1].poses[actualPart.Name]
if info then
C1 = info.bodyPartCFrame
end
print("Yuppo")
end
for keyframeIndex, keyframe in pairs(definingText) do
if keyframeIndex ~= 1 then
local timeForLoopNow = keyframe.time
local timeForLoopLater = definingText[math.clamp(keyframeIndex +1, 1, #definingText)].time
local timeBetween = timeForLoopLater - timeForLoopNow
for currentProgress = 1, 1000 do
for _, motor6D in pairs(motor6Ds) do
local actualPart = motor6D.Part1
local C1 = motor6D.C1
local info = keyframe.poses[actualPart.Name]
local positionBefore = definingText[keyframeIndex-math.clamp(keyframeIndex-1, 0, 1)].poses[actualPart.Name].bodyPartCFrame
C1 = positionBefore:Lerp(info.bodyPartCFrame, currentProgress/10)
print(timeBetween)
wait(0.01)
end
end
end
end
end
--print(require(game.ServerStorage.animationConverter).createDefiningText(workspace.Dummy.AnimSaves.walk))
--local mod = require(game.ServerStorage.animationConverter) local text = mod.createDefiningText(workspace.Dummy.AnimSaves.walk) print(text) mod.playAnimation(text, workspace.Cxsnls)
return animationConverter