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

LoadAnimation requires humanoid to be a descendant of game object” What is my error?

Asked by 7 years ago

This is the code. A localscript inside a tool. what is the error?

local anim = Instance.new(“Animation”)
anim.AnimationId = “rbxassetid://1188415703”
anim.Parent = script.Parent
anim.Name = “CardHold”
local key = script.Parent
local hum = game.Players.LocalPlayer.Character.Humanoid
local animTrack = hum:LoadAnimation(anim)

key.Equipped:Connect(function()
    animTrack:Play()
end)

key.Unequipped:Connect(function()
    animTrack:Stop()
end)

0
Your quotations for the strings are the wrong character. Your quotations should look like a " and always face the same direction. This goes for every other major programming language as well. RayCurse 1518 — 7y
0
i did that there’s only 1 quotation key in a keyboard lol Reconozco 0 — 7y
0
He is right, your quotation are off. They should be highlighting the words that they are qoutating. But there not. GottaHaveAFunTime 218 — 7y
0
add a wait for the character doesn't load immediately so add a wait(1) then the character should be loaded unless your connection is slow GameBoyOtaku 63 — 7y
0
i dont think roblox supports those kind of quotes, you can also try using ' or just copy and paste " Astralyst 389 — 7y

2 answers

Log in to vote
0
Answered by
Astralyst 389 Moderation Voter
7 years ago
Edited 7 years ago

if you look closely at your quotations,

--[[ they look like this.
“CardHold”
look at where the ends are pointing at, it should look like this instead.

"CardHold"

tldr:

use this: ""
and not this: “”--]]

surely roblox should give you an error when you did that, cause it's an unknown symbol.

if your keyboard only has those type of quotation marks, you can just copy and paste these here.

--[[
"rbxassetid://1188415703"
("Animation")
"CardHold"
--]]
0
Obviously it is his computer, the problem is something most game developers run into. Sorry, man ReadyHappiness 109 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

The problem is not your quotations. It is a problem i once ran into aswell.

The animation track thinks the character is nil. So instead of your code, try this:

local anim = Instance.new(“Animation”)
anim.AnimationId = “rbxassetid://1188415703”
anim.Parent = script.Parent
anim.Name = “CardHold”
local key = script.Parent
local hum = game.Players.LocalPlayer.Character.Humanoid
local animTrack = hum:LoadAnimation(anim)

while char.Parent == nil do
    char.AncestryChanged:wait()
end

key.Equipped:Connect(function()
    animTrack:Play()
end)

key.Unequipped:Connect(function()
    animTrack:Stop()
end)

Do you notice the new part in the code? This is there to keep the tool from animating until the character is not nil. Why they think its nil: i dont know why. Do I care: no.

Glad to help you!

ReadyHappiness

0
Well, I have looked at many sites on this issue but nothing really works. All solutions are no good to me, and I can't even log on to DevForum for some reason. Phyrixia 51 — 4y

Answer this question