Getting error "LoadAnimation requires the Humanoid object to be a descendant of the game object" despite waiting for Character

I keep getting this error whenever I attempt to call :LoadAnimation() on the humanoid. The localscript is located in the player’s StarterPack. Here’s the code:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local hum = char:WaitForChild("Humanoid")
local root = char:WaitForChild("HumanoidRootPart")

local anim ="Animation")
anim.AnimationId = "
local animTrack = hum:LoadAnimation(anim)

As you can see, I wait for the humanoid to exist, yet I still get the error. It only seems to happen in Studio, but it’s really hindering when you want to test. Here’s a repro:

Humanoid Error Repro.rbxl (10.9 KB)


If you print char.Parent before calling LoadAnimation, is it nil?

You can add the following before you wait for the humanoid to make sure that character is parented to workspace.

while char.Parent == nil do

Yeah, it is. I realise there are ways to work around the issue, like using the code you posted, however it only started happening recently as I’ve used the code in OP for ages now without any problems. That being said, most people, including myself, don’t like to use workarounds so I figured this would be an issue worth looking into.


This is still an issue, I’ve been having trouble trying to get around it. The repro file in the OP still gives the error as well.


This seems to be expected behavior, therefore not an issue. See @TheGamer101’s response above.

1 Like

Yeah, the problem here is that the DataModel (“game” object) isn’t global, and since services are parented to DataModel, you can’t use services without having a DataModel. LoadAnimation and a number of other API members need one or more of those services, so they can’t function without a DataModel either.

I wish this weren’t an issue because parent restrictions like this require hacky workarounds (e.g. I have to either parent entities to workspace as soon as I create them to load animations instead of letting the script that created them do the parenting, or have the scripts ask the entity to set its own parent where I can load animations there.), but I guess we’re stuck with it for now.