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

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

Asked by 6 years ago

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"))
0
You could add a wait(3) or whatever number you want after local start = GottaHaveAFunTime 218 — 6y

2 answers

Log in to vote
0
Answered by
xEiffel 280 Moderation Voter
6 years ago

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"))
0
True but there's more to it than that CootKitty 311 — 6y
0
No, or else it would not error the same error. hiimgoodpack 2009 — 6y
Ad
Log in to vote
0
Answered by
CootKitty 311 Moderation Voter
6 years ago
Edited 6 years ago

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()
0
The reason that does not work is because you misspelled :Wait() hiimgoodpack 2009 — 6y
0
it's an example you know what I mean read the damn answer noob get rekt CootKitty 311 — 6y

Answer this question