KeyframeReached not working

So I’m trying to make a script where it finds the position of a part when an animation is playing, but it seems that .KeyframeReached is not working.

I tried a forum that a roblox staff member replied to and his script worked for a little bit and then it broke when I went back to it.

Here is the script I am using.

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(KeyCode)
	KeyCode = KeyCode.KeyCode
	if (KeyCode == Enum.KeyCode.E) then
		local Animation = Instance.new("Animation")
		Animation.AnimationId = "rbxassetid://5799073368"
		local Character = script.Parent
		local Humanoid = Character.Humanoid
		local AnimTrack = Humanoid:LoadAnimation(Animation)
		AnimTrack.KeyframeReached:Connect(function(Name)
			print("Keyframe: " .. Name)
		end)
		AnimTrack:Play()
	end
end)

Here is a video of my problem.
[https://youtu.be/TOxijT5Y-us]

1 Like

While this still works, it’s more recommended to use the new GetMarkerReachedSignal event now. It could also return a parameter when specified.

I just looked, it finds if it reached a specific Keyframe defined by name. I would like it so I don’t have to set the name for each animation.