Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does the KeyframeReached event not fire? [UNSOLVED]

I'm trying to make an animation not run a second time until it is finished running the first time. The problem is, however, that the animation only runs once because the KeyframeReached event does not fire. This is a local script in starter gui and nothing appears in the output -- at all.

local plr = game.Players.LocalPlayer
	repeat wait() until plr.Character
local hum = plr.Character:WaitForChild("Humanoid")
local mouse = plr:GetMouse()
local anim = workspace:WaitForChild("Animation")
local canPlay = true

mouse.KeyDown:connect(function(key)
	if key:lower() == "q" and canPlay then
		canPlay = false
		local animTrack = hum:LoadAnimation(anim)
		
		animTrack.KeyframeReached:connect(function(name)
			print("fired")--Does not print
			print(name)--Does not print
			if name == "End" then
				canPlay = true
			end
		end)
		
		animTrack:Play()
	end
end)

1 answer

The only possibility I can think of is that the animation only has one keyframe, but I'm doubtful that the aforementioned instance is the case. Unless the issue has to do with a bug in animations, the issue is most likely how you ran the script. Also, the issue could also be with the script itself( other scripts tampering with the script ).

2 comments

0

There are multiple keyframes, although only the last one has a name. There are no scripts messing this script up. This script is the only script in the game. The only other objects are the BasePlate and Animation in workspace.

0

Are you testing this in Studio? My best guess as of now is that Offline Mode is showing results different than Online Mode.

This discussion is preserved as it was. New answers, comments, and votes are closed.