I’ve tried pretty much everything I can to combat this error and it still persists for absolutely no good reason.
I’ve tried:
Waiting until the character is in workspace
Waiting for the HumanoidRootPart to load in
Ensuring that the AnimationClipProvider Service is loaded in via game:GetService
printing out the humanoid, character model, and animation that is trying to be loaded
waiting an additional 1.5 seconds
(I have also restarted studio and the exact same error persists)
while not script:FindFirstAncestorWhichIsA("Workspace") do
RunService.Heartbeat:Wait()
end
game:GetService("AnimationClipProvider")
task.wait(1.5)
Character:WaitForChild("HumanoidRootPart")
print("in workspace!", myHum, Character, Character:FindFirstChild("attackanim"))
print(myHum:LoadAnimation(Character:WaitForChild("attackanim")))
If anyone has any sane clue as to what’s going on any information would be very much appreciated.
I’m also calling the code above from a function in a module script which looks more like this:
ModuleScript:
Stats.AI = function()
setfenv(1, getfenv(2))
while not script:FindFirstAncestorWhichIsA("Workspace") do
RunService.Heartbeat:Wait()
end
game:GetService("AnimationClipProvider")
task.wait(1.5)
Character:WaitForChild("HumanoidRootPart")
print("in workspace!", myHum, Character, Character:FindFirstChild("attackanim"))
print(myHum:LoadAnimation(Character:WaitForChild("attackanim")))
... -- rest of the code
end
I think you are trying to load the animation in a deprecated way, by loading into Humanoid, you should load it using the Animator: myHum.Animator:LoadAnimation(Character:WaitForChild("attackanim")):Play()
The waits you added are not really needed, depends from where you are getting the character and how. I had a similar issue, but it was for Player not an NPC, and I waited for all its instances before load the track, even the Animator I was sure it existed. Still failing, and by adding a RunService step:Wait() it got fixed. But your issue seems more like forgeting to use the Animator to load the animation
The animation is an animation uploaded by Roblox, and was working prior to it suddenly stopping so I don’t think this is the issue.
Similar response to the response above, the animation was working perfectly fine until it randomly stopped working. I doubt this is the issue, but I’ll check it out anyways because you never know .
Edit: Unfortunately loading the animation from the animator had no effect on this issue, and resulted in the exact same error.
while not script:FindFirstAncestorWhichIsA("Workspace") do
RunService.Heartbeat:Wait()
end
Instance.new("Animator", myHum)
game:GetService("AnimationClipProvider")
task.wait(1.5)
Character:WaitForChild("HumanoidRootPart")
print("in workspace!", myHum, Character, Character:FindFirstChild("attackanim"), myHum.Animator)
print(myHum.Animator:LoadAnimation(Character:WaitForChild("attackanim")))