I’m making a tool that has a local script inside of it, which handles the animations. The tool is also placed inside the StarterPack.
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animation = tool:WaitForChild("Animation")
local animationTrack = animator:LoadAnimation(animationTrack)
The animation works when the character first loads, but when they reset the error, “Cannot load the AnimationClipProvider Service.” shows up on the line where the animation is supposed to load the animation.
There’s two other posts about this error where people suggested to stick a repeat loop before the animation is loaded to wait until the character is a descendent or parented to the workspace. But when I tried to do that the script just yields forever. (which is weird because the character is loaded)
I think this is a Roblox bug, so if there is a workaround let me know.
This is not a bug per se, what’s most likely happening is you are trying to load the animation when the character is parented to nill; verify this by doing print(character.Parent); and when you do that it raises that error. So all you gotta do is make sure the character is not parented to nil when loading the animation.
So I used to have the same problem with my gun tool but ive come up with a good solution
My Script:
local player = game:GetService("Players").LocalPlayer
local Character
local Humanoid
local Animator
local AnimationTrack
local tool = script.Parent
Tool.Equipped:Connect(function()
Character = player.Character
Humanoid = Character:WaitForChild("Humanoid")
Animator = Humanoid.Animator
AnimationTrack = Animator:LoadAnimation(ANIMATION U WANT TO PLAY)
AnimationTrack:Play()
end)
And then you can also stop the animation with when u unequip the tool. Hopefully this helps you.
I edited the code so that it only loads the animation once when the tool is equipped.
local player = game:GetService("Players").LocalPlayer
local character
local humanoid
local animator
local animationTrack
local tool = script.Parent
tool.Equipped:Connect(function()
if not character then
character = player.Character or player.CharacterAdded:Wait()
humanoid = character:WaitForChild("Humanoid")
animator = humanoid:WaitForChild("Animator")
animationTrack = animator:LoadAnimation(ANIMATION U WANT TO PLAY)
end
end)