The AnimationTrack.Stopped event triggers whenever your animation stops (or hit the last keyframe).
As said by the screen, it is useful when you are trying to chain a series of animations or when you are trying to add visuals.
What you could do is:
local animation = script:WaitForChild("Animation")
local playerCharacter = game.Players.LocalPlayer.Character
local humanoid = playerCharacter:WaitForChild("Humanoid")
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()
animationTrack.Stopped:Wait()
print("The animation stopped.")
I believe it fires when the animation is cancelled, yes.
You can still try by adding animationTrack:Stop() and see if it fires the .Stopped function.
(Make sure to mark my message as the Solution if it helped you, to close the topic.)
Yeah, that is correct.
However, in my game, I let the player cancel the action (if they want to), and I would want to know whether or not they actually did the whole action/animation or canceled it before it started. (Preferably without using the :Wait().)
you could use another variable when stopping the animation to determine that; for example
local forcedStop
animationTrack.Stopped:Connect(function()
if forcedStop then
--the animation didnt finish playing
else
-- the animation finished playing
end
end)
forcedStop = true
animationTrack:Stop()