For anyone facing this problem, it’s typically caused by attempting to load an animation before the AnimationClipProvider service has loaded itself (it’s loaded by CoreScripts), to circumvent this issue you can add a small yield (delay) between the script’s execution starting and the animation loading, i.e;
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
if not player:HasAppearanceLoaded() then player.CharacterAppearanceLoaded:Wait() end
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animation = script:WaitForChild("Animation") --Animation placed inside script.
task.wait() --Yield here, increase delay if necessary.
local track = animator:LoadAnimation(animation)
repeat task.wait() until track.Length > 0
track:Play()
While using Studios multiple Clients and Servers Test feature It gave me the same error for every test client that joined. The error was limited to server scripts only so the animations played by test clients were working and i don’t think the issue happened because the server script executed before AnimationClipProvider service has loaded since resetting the test client character gave the same error again
while task.wait (0.01) do
warn("THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU")
end
Hey roblox, i’m looking at you. Please fix this bug.
Okay so I found a solution to this, however it might not be one for a lot of you guys (I used Promise.lua)
--// My Util Module
local myUtil = {}
local function loadAnimation(hum, anim)
return Promise.new(function(resolve, reject)
local animTrack;
local success, output = pcall(function()
animTrack = hum:LoadAnimation(anim)
end)
if not success then
reject()
else
resolve(animTrack)
end
end)
end
function myUtil:fetchAnimTrack(hum,anim)
return Promise.retryWithDelay(
loadAnimation, 5, 1,
hum, anim
):expect()
end
return myUtil
This function safely loads any AnimationTracks and returns them.
This is the solution, thanks! I hope the post author marks your answer. What I did was I made sure to parent my npc to workspace before loading animations!
Wanted to add my tuppence while this is still considered current.
I have found it necessary to wait a small time after player.CharacterAdded:Connect(onCharacterAdded) fires.
I don’t actually call wait or task.wait, which is generally frowned upon, not that would stop me. Instead I add accessories (just my hat) which seems to impart all the delay I need. Here are my timings:
23:30:54.818 too soon to `animator:LoadAnimation(animation)`
23:30:55.114 1772336109 Enum.AccessoryType.Hat
23:30:55.428 not too soon to `animator:LoadAnimation(animation)`
So yeah, I’m effectively waiting some arbitrary time of about 0.5s, which is bad practice, but it works so why complain?
The elaborate solutions above look nice, but there is nothing specifically to wait for, in either case (both too soon and not too soon):
print(player.Character.Humanoid.Parent.Parent)
returned nil. Which I don’t understand because:
player.Character.Humanoid.Parent.Parent == player.Character.Parent == player
Nothing is impossible, or completely broken, my last answer got me thinking. We do have something to wait for; the success of the call itself.
In lua we handle exceptions using pcall. The canonical solution is therefore:
function safelyLoadTrack(animator: Animator, animation: Animation): AnimationTrack
local success, errorOrData
repeat
success, errorOrData = pcall(function()
return animator:LoadAnimation(animation)
end)
if not success then
warn(errorOrData) -- We're calling it too early but ideally we'd check that with this error message, which we can at least preserve verbatim.
task.wait(0.2)
end
until success
return errorOrData
end
A word of caution on exception handling, don’t ignore errors. Ideally we’d test the errorOrData message is what we expect, and not something pertaining to a non-existant, or bad, animation, or the servers being down.
The error message I expect is:
Cannot load the AnimationClipProvider Service.
but that isn’t formally specified nor guaranteed not to change with future updates.
for me personally the fix wasnt any waits or nothing it was simply the fact i played 2 same animations at the same time that caused the error for me, i had an ancestry changed event connected to an instance that was parented to the character, which after its deleted, plays an animation, i also had a play animation on respawn, since my respawn time was low it was pretty much instant so both (same animations) tried to play vs each other giving me the error, after adding a health>0 check in my ancestry event the error is gone maybe someone has this exact problem if so theres ur fix