Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago
Edited 3 years ago

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

0
Wow Thanks For Providing Code For Us To Help You With zadobyte 692 — 3y
0
Thank You For Blessing Us With The Power Of "No Code" User#30567 0 — 3y
0
Where is your code? zane21225 243 — 3y
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 spectacularnicknack 2 — 3y

1 answer

Log in to vote
0
Answered by
A_thruZ 29
3 years ago

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)
Ad

Answer this question