:Once() not firing but :Wait() works?

So I’ve got an animation playing, it’s playing correctly, however, the .Ending event doesn’t fire if connected with :Once() or :Connect(), but does if I use :Wait(). The animation is ending correctly (.IsPlaying printing true and then false when it ended), there are no other animations playing, and the craziest thing is that it works in other scripts, literally being structured exactly / almost the same as this one.

local animation = Libraries.Handlers.AnimationsHandler:PlayAnimation(character, animationId)
animation.Looped = false
animation.Priority = Enum.AnimationPriority.Action4
	
humanoid.WalkSpeed = Settings.Player.DefaultWalkSpeed / 3
humanoid.JumpPower = 0
	
animation:GetMarkerReachedSignal("Shoot"):Once(function()
	print("shoot")
end)

animation.Ended:Once(function()
	print("ended")
end)

This is the whole code inside of a function, there’s nothing else, “shoot” is printing, but “ended” is not, unless I use :Wait() instead of :Once() or :Connect(). Am I missing something?
Thank you for your time!

1 Like

If this is the case make the function a variable then use :Wait() and disconnect the connection of the function right after.

local animation = Libraries.Handlers.AnimationsHandler:PlayAnimation(character, animationId)
animation.Looped = false
animation.Priority = Enum.AnimationPriority.Action4
	
for _, v in character.Humanoid:GetPlayingAnimationTracks() do
	print(v)
end

humanoid.WalkSpeed = Settings.Player.DefaultWalkSpeed / 3
humanoid.JumpPower = 0
	
animation:GetMarkerReachedSignal("Shoot"):Once(function()
	print("shoot")
end)

animation.Ended:Once(function()
	print("ended")
end)

I just added that print and it works now? I really don’t understand…
Without that print it just doesn’t print “ended” :skull: