Animation Markers delayed on first run

I’m having a problem where my animations is fully loaded but not my animation markers.
The first time I run the animation all the markers are delayed and after that everything is fine.

I tried preloading animations 1 by 1 on a rig (I tried loading it with different speed (1-10), use KeyframeReached but still I get the same result.

Preloading Script
local function OnCompletion(ContentId, Status)
	if Status == Enum.AssetFetchStatus.Success then
		print("Succesfuly Loaded: " .. ContentId)
	elseif Status == Enum.AssetFetchStatus.Failure then
		print("It was not possible to load: " .. ContentId)
	end
end

ContentProviderService:PreloadAsync(TagService:GetTagged("EssentialLoad"), OnCompletion())
for _, v in pairs(TagService:GetTagged("EssentialLoad")) do
	if v:IsA("Animation") then
		local Humanoid = workspace:WaitForChild("Dummies"):WaitForChild("AnimationLoaderDummy"):WaitForChild("Humanoid")
		local LoadAnim = _G.AnimLoad(Humanoid, v.AnimationId)
		LoadAnim:Play()
		LoadAnim:AdjustSpeed(10)
		LoadAnim.Looped = false
		LoadAnim.Stopped:Wait()
	end
end
3 Likes

Need to fix this problem asap its urgent

2 Likes

Instead of relying on Stopped:Wait() , you can use the KeyframeReached event to detect when the animation reaches a specific keyframe, ensuring that the animation has progressed to a certain point before proceeding.

LoadAnim.KeyframeReached:Connect(function(frame)
    if frame == LoadAnim.Length then
        -- Animation reached the end, perform any necessary actions here
    end
end)

Also Instead of loading all animations simultaneously, you might want to load them sequentially. This can help ensure that the markers are initialized before the next animation starts.

for _, v in pairs(TagService:GetTagged("EssentialLoad")) do
    if v:IsA("Animation") then
        local Humanoid = workspace:WaitForChild("Dummies"):WaitForChild("AnimationLoaderDummy"):WaitForChild("Humanoid")
        local LoadAnim = _G.AnimLoad(Humanoid, v.AnimationId)
        LoadAnim:Play()
        LoadAnim:AdjustSpeed(10)
        LoadAnim.Looped = false
        LoadAnim.Stopped:Wait()
    end
end

Ans stop relying solely on the Stopped event, you can handle events more granularly to make sure that everything is ready before proceeding.

2 Likes

Tried using the KeyframeReached method and loading them sequentially. Still delayed on the first run.

1 Like

I think I found a fix, I loaded all the animations on the server and it works. Since most of my script are server sided for combat.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.