How do we get Animation Duration?

I want to get the duration of an animation, so I can script it. Is there a way to get animation duration as a script? I tried doing this, but it keeps printing out 0 instead.

local Grab01 = plr.Character.Humanoid:LoadAnimation(script.Parent.Parent.Grab01)
local Grab02 = hit.Parent.Humanoid:LoadAnimation(script.Parent.Parent.Grab02)
delay(0.1, function()
	Grab01:Play()						
end)
Grab02:Play()
print(Grab01.Length)
print(Grab02.Length)

image

2 Likes

“A read only property that returns the length (in seconds) of an AnimationTrack . This will return 0 until the animation has fully loaded and thus may not be immediately available.”

So how do I get the duration, what do you mean by “fully loaded”. Can I “fully load” the animation using a script? Or do I have to finish playing the animation once in order to get it to “fully load”? Please elaborate further for me to understand.

1 Like
local Track = Animator:LoadAnimation(Animation)
repeat task.wait() until Track.Length > 0
print(Track.Length)
11 Likes

I’ve found that solution yesterday, but thanks. I’ll mark it as a solution. I also forgot to type in the solution yesterday, was busy with class.