GetTimeOfKeyframe is yielding a nil error

hey, does anyone know how to fix this problem? I’m trying to get the time between a KeyframeMarker to another KeyframeMarker, but it doesn’t seem to be working, as it’s throwing an error

transformation_event.OnServerEvent:Connect(function(player, animator)
  local start_transform = anim_track:GetTimeOfKeyframe("transform")
  local start_manifest = anim_track:GetTimeOfKeyframe("manifest")
  local period = (start_transform - start_manifest)
  print(start_manifest)
  print(start_transform)
  print(period)

  anim_track = animator: LoadAnimation(animation)
  manifest = anim_track:GetMarkerReachedSignal("manifest") transform = 
  anim_track:GetMarkerReachedSignal("transform")

  anim_track:Play()

  transform:Connect(function(param)
    anim_track: AdjustSpeed(0.0001)
    --shake_event:FireClient(player, period, 200)
    task.wait(param)
    anim_track:AdjustSpeed(1)
  end)
end)

it’s saying that the keyframe doesn’t have a name, however I already set their names
image

if anyone has any solutions, please let me know! thank you :slight_smile:

GetTimeOfKeyframe will also throw an error when called before the animation has finished loading as stated here in the docs

1 Like

it worked, thank you so much! :))

1 Like


hey, I have this error where it says Invalid operation for this animation format. Do you know why this happens?

You’re not waiting for the animation to load correctly. Replace:
transform = anim_track:GetMarkerReachedSignal("transform")
With:
repeat task.wait() until anim_track.Length > 0

Important edit: Although if you’re using that line for something else, place the line I gave you to wait for the animation to load before that line and you should be ok

1 Like

OHH IT FINALLY WORKED, THANK YOU SO MUCHHH :heart:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.