Getting the cframe doesn’t work but getting the keyframe time does?Basically when it gets the cframe it returns 0 keyframes whereas in the time it returns all the keyframes.
function module.getanimationlength(Animation,Type)
local AssetId = Animation.AnimationId
local Sequence = Provider:GetKeyframeSequenceAsync(AssetId)
local Keyframes = Sequence:GetKeyframes()
if Type == "E" then
print("eee")
if CFrameCache[AssetId] then
return CFrameCache[AssetId]
end
local first
--for i,v in pairs(Keyframes[2]:GetDescendants()) do
-- if v.Name == "RightHand" then
-- first = v.CFrame
-- end
--end
local second
--for i,v in pairs(Keyframes[#Keyframes-1]:GetDescendants()) do
-- if v.Name == "RightHand" then
-- second = v.CFrame
-- end
-- end
for i = 1, #Keyframes do
print(i)
if i == 1 then
first = Keyframes[i].CFrame
elseif i == #Keyframes then
second = Keyframes[i].CFrame
end
end
Sequence:Destroy()
if second and first then
CFrameCache[AssetId] = {first,second}
return {first,second}
end
else
if Cache[AssetId] then
return Cache[AssetId]
end
local Length = 0
for i = 1, #Keyframes do
local Time = Keyframes[i].Time
if Time > Length then
Length = Time
end
end
Cache[AssetId] = Length
Sequence:Destroy()
return Length
end
end
I’m not an animation expert at all, but you are not checking the CFrame of a part, you are checking the CFrame of a Keyframe, which obviously doesn’t exist. I did some research and Keyframes have poses and poses have the CFrame of the Motor6D that is modifying a part and poses even have the same name as the part it’s applied to. So, perhaps use GetPoses(), find the one with the name of the part you’re looking for (I think you want Right Hand?) and apply the pose’s CFrame to the same Motor6d in a copy of the model and then it will have the CFrame you are looking for. Hope I helped!
First of all I want you to remove all lines where it trys to get the CFrame of the keyframes, it’s going to error. That may already solve your problem.