GetTimeOfKeyframe Not Working

local animation = Instance.new("Animation", self.animationFolder)
animation.Name = animName
animation.AnimationId = animID
local track = self.animationController:LoadAnimation(animation)
self.animationTracks[animName] = track
if animName == "reload" then
   print(track:GetTimeOfKeyframe("MagDisappear"))
end

For some reason, when I try printing the time at the key frame “MagDisappear”, it throws this error:

image

Even though there’s obviously a keyframe at that point of the animation with that name:

Any clue what’s going on? GetMarkerReachedSignal works, but sometimes it doesn’t fire because the animation has not loaded yet, even after I called local track = self.animationController:LoadAnimation(animation)

The keyframe in your screenshot is named “MagAppear”, not “MagDisappear”

My bad, sent wrong image. Check again.

Is MagDisappear a keyframe marker or a named keyframe? Asking for the same of clarification and so I don’t assert something which may not be true.

GetTimeOfKeyframe only works with a named keyframe. The error you’re getting suggests that you don’t have a named keyframe, as does the fact that GetMarkerReachedSignal works for it. Consulting documentation and reading the error would’ve been helpful in figuring this out.

Before it’s asked, by the way: an equivalent to GetTimeOfKeyframe for markers does not exist.

2 Likes