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 4 years ago
Edited 4 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:

1local player = game.Players.LocalPlayer
2local char = player.Character or player.CharacterAdded:Wait()
3local humanoid = char:WaitForChild("Humanoid")
4 
5local anim = Instance.new("Animation")
6anim.AnimationId = "rbxassetid://5595931188"
7local 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 — 4y
0
Thank You For Blessing Us With The Power Of "No Code" User#30567 0 — 4y
0
Where is your code? zane21225 243 — 4y
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 — 4y

1 answer

Log in to vote
0
Answered by
A_thruZ 29
4 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:

01local player = game.Players.LocalPlayer
02local char = player.Character or player.CharacterAdded:Wait()
03local humanoid = char:WaitForChild("Humanoid")
04 
05 
06local anim = Instance.new("Animation")
07anim.AnimationId = "rbxassetid://5595931188"
08 
09player.CharacterAdded:Connect(function()
10    local animation = humanoid:LoadAnimation(anim)
11end)
Ad

Answer this question