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