Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

LoadAnimation requires the Humanoid object to be a descendant of the game object (?)

ok this error has been coming up for soo long: LoadAnimation requires the Humanoid object (DragonSpawner12.Humanoid) to be a descendant of the game object

Here is my code:

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://5595931188"
local animation = humanoid:LoadAnimation(anim)

I HAVE SEEN SO MANY ARTICLES NOT SOLVING THIS!

PLEASE Help me!

Edit: thanks for the inspiring comments

4 comments

0

Wow Thanks For Providing Code For Us To Help You With

0

Thank You For Blessing Us With The Power Of "No Code"

0

Where is your code?

0

is that the entire code that is making the error?,but i searched it and it said you cant change the parent of the load animation

1 answer

From the looks of it, this runs on a LocalScript, so it most likely loads much before the character. The code should work modified like this:

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")


local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://5595931188"

player.CharacterAdded:Connect(function()
	local animation = humanoid:LoadAnimation(anim)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.