local rs = game:GetService("RunService")
-- Add this at the start of your second for loop
rs.Heartbeat:Wait()
could fix it. For me whenever I have this issue, adding a load wait works. Especially a heartbeat wait. Even if heartbeat isn’t enough, you can add task.wait(0.5) (or tone it down to 0.1).
Another cause could be parent not being initialized as a result of duplicated, check for that. Though, I highly doubt that’s it, and a load wait would probably be enough.
I know that this may be a necropost, but I’m getting this error now. I’ve set up a tool.equipped:wait() before loading the animation, and that still didn’t fix it. It works fine the first time the character loads, but respawning makes it refuse to work. I even at one point used a task.wait(3) to test, and THAT didn’t fix it. Also tried heartbeat, stepped, etc. I’m so confused, I just want to throw a snowball. : (
local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
Tool.Equipped:Wait()
local ThrowAnimation = Character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(Tool:WaitForChild("ThrowAnim"))
there’s most likely a similar block of code here but I made a module for this a while ago and it’s been working fantastically for me.
local module = {}
function module:LoadAnimation(animation:Animation,animator:Animator)
local success, errorMsg = nil, nil
local Animation = nil
local tryCount = 0
repeat
task.wait(1)
success, errorMsg = pcall(function()
Animation = animator:LoadAnimation(animation)
end)
if success == false then
tryCount += 1
warn(errorMsg, "retrying...")
end
until success == true or tryCount == 5
return Animation
end
return module
I made this for a game I was working on and I went to this post and absolutely none of the solutions were working, I remember I did a 30 second yield once and it still gave me the error. I despise this bug, it needs to be fixed.
code might not be the best since I made it a while ago so feel free to make improvements
I’ve fixed my issue, I believe I may have a theory as to why this glitch is occurring; the dummy/NPC/Humanoid must be in workspace whilst calling :LoadAnimation() on it, otherwise this error occurs.
I’m not sure why this has to be done intentionally, but anyone who says it needs to be parented is correct. You HAVE to parent it first before it could actually load the animation which is really annoying. I wish the LoadAnimation() function could just do this themselves but no. So yes, essentially you’d have to parent the model of which you are trying to load the animation for BEFORE calling LoadAnimation on your Animator. I have tried doing this in ReplicatedStorage and it seems to be working just fine. You can do workspace too, and probably StarterGui if the model is inside a ViewportFrame.
Hello developers, now I kinda have found a way to fix the issue.
So first of all, you cannot use :LoadAnimation() on Characters those aren’t parented to workspace
to fix this, I parent my character into somewhere inside workspace
local Plr = game.Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
Char.Parent = workspace
hope this help !
: mostly happens with StarterCharacter&Tools
My NPCs are loaded into workspace before they receive the script that load animations and yet it still happens. I see the error in the analytics, but I can’t find it in the in-game logs or reproduce it in studio.
Roblox engine is just full of problems and unreliable and we need to live with it…
(That’s only over the last 24h)
Same here, I explicitly put some lines to check if the NPC is in workspace before calling loadanimation, and if it isn’t i put it in the workspace, but I’m still getting thousands of these errors. Not only that, I also wrap LoadAnimation in a pcall so I honestly do not understand why its not being silenced and still ending up in the error log. The error never happens in studio
Hey! So I never updated the post, but it seems to be coming from roblox internal scripts, I later realized that the “Type” is “Client” and my NPCs runs with a server script, so wasn’t that.
Adding their “Animate” script in StarterCharacterScripts (Copy-Paste the one inside a character) and adding this line at the top of the “playAnimation” function seems to have fixed the issue for me
if not humanoid:IsDescendantOf(workspace) then
return
end