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

Why does loadanimation not work in my script, and says humanoid needs of be descendant of game?

there's a character and humanoid varible, but everytime I tried to use this, it would always say humanoid needs to be a descendant of game object to use loadanimation, or something along those lines.

local start = humanoid:LoadAnimation(Character:WaitForChild("Animations"):WaitForChild("MagicStart"))

1 comment

0

You could add a wait(3) or whatever number you want after local start =

2 answers

You haven't given it enough time to load for the humanoid, or as so I think. Do this, then run that.

(variable):WaitForChild('humanoid')
local start = humanoid:LoadAnimation(Character:WaitForChild("Animations"):WaitForChild("MagicStart"))

2 comments

0

True but there's more to it than that

0

No, or else it would not error the same error.

So, often times people do this:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Waiti()
local humanoid = char:WaitForChild("Humanoid")
local animationTrack = humanoid:LoadAnimation(x)

However, this doesn't work often times.

The reason why is that, even though the player has a character, the character doesn't get put into workspace by the game instantly. So simply use this:

-- local script
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Waiti()
local humanoid = char:WaitForChild("Humanoid")
char.Parent = workspace
local start = humanoid:LoadAnimation(char:WaitForChild("Animations"):WaitForChild("MagicStart"))

-- when you want: start:Play()

2 comments

0

The reason that does not work is because you misspelled :Wait()

0

it's an example you know what I mean read the damn answer noob get rekt

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