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

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

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)

5 comments

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.

0

i did that there’s only 1 quotation key in a keyboard lol

0

He is right, your quotation are off. They should be highlighting the words that they are qoutating. But there not.

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

0

i dont think roblox supports those kind of quotes, you can also try using ' or just copy and paste "

2 answers

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"
--]]

1 comment

0

Obviously it is his computer, the problem is something most game developers run into. Sorry, man

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

1 comment

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.

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