Issue with Animation Events (GetMarkerReachedSignal)

Okay, I have made many posts investigating this issue in my game and made a lot of discoveries, so I hope someone who has experience with animations will be able to help!

I became aware of this issue after someone reported that none of the Loot Boxes in the server would disappear after being collected. I was always pretty much sure the code wasn’t broken and it had something to do with animations/animation events.

Today I finally confirmed that was the case.

When I joined a server with this issue present, I first checked the output and like I expected, no error outputs other than some animations not being loaded. I then tried opening some chests myself and the animation would play despite the animation event not working, which is odd.

Output (Server-Side):

Adsız

Sure enough, the ID of the Chest Opening Animation was there, among the assets that failed to load. But it would still play when I opened it?

Anyways, here is the simplified version of the loot box’s code!

--loads and plays animation
used = false
local Humanoid = script.Parent.Parent.Parent.ObjectHumanoid
local Move = script.Move
local MoveAnim = Humanoid.Animator:LoadAnimation(Move)
local Idle = script.Idle
local IdleAnim = Humanoid.Animator:LoadAnimation(Idle)
IdleAnim:Play()
--makes the box visible
for i = 1,10 do
	task.wait(0.05)
	script.Parent.Parent.Transparency = script.Parent.Parent.Transparency - 0.1
end
--stops idle animation and plays opening animation upon triggering Proximity Prompt
script.Parent.Triggered:Connect(function(player)
	if player.Character:FindFirstChildOfClass("Humanoid") ~= nil and used == false then
		used = true
		script.Parent.Enabled = false
		IdleAnim:Stop()
		MoveAnim:Play()
	end
end)
--detects when the opening animation ends, freezes the animation and makes it disappear
MoveAnim:GetMarkerReachedSignal("Ended"):Connect(function()
	MoveAnim:AdjustSpeed(0)
	for i = 1,10 do
		task.wait(0.05)
		script.Parent.Parent.Transparency = script.Parent.Parent.Transparency + 0.1
	end
	script.Parent.Parent.Parent:Destroy()
end)

I’d be happy if someone can shine light on what’s going on here. Why does it say that the animation failed to load in server-side outputs? Why does it fail to detect the animation event despite it playing perfectly when opened? How can I make sure it loads every time? (I use a preload btw)

1 Like

Have you found a solution? I use this code, it works without errors, but it seems to me that synchronization with animation is a bit worse

function module.AnimTime(args)
	local track = args.Track
	local basetimepos = args.TimePos
	local tp = basetimepos
	local func = args.Func
	local interval = args.Interval or 0
	local times = args.Times or 1
	if func then
		for i=1,times do
			repeat task.wait() until track.TimePosition > tp or not track.IsPlaying
			func()
			tp = tp + interval
		end
	else
		repeat task.wait() until track.TimePosition > tp or not track.IsPlaying
	end
end