Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does the KeyframeReached event not fire? [UNSOLVED]

Asked by 9 years ago

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

Log in to vote
0
Answered by
Diitto 230 Moderation Voter
9 years ago

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 ).

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. ZeptixBlade 215 — 9y
0
Are you testing this in Studio? My best guess as of now is that Offline Mode is showing results different than Online Mode. Diitto 230 — 9y
Ad

Answer this question