[Error] LoadAnimation requires the Humanoid object to be a descendant of the game object

How do I fix this error? Comes only when my character resets/dies not on the first join.

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local A = Instance.new("Animation")
A.AnimationId = "rbxassetid://6188093326"
local Hum = char:WaitForChild'Humanoid'
local Anim = Hum.Animator:LoadAnimation(A)

Error
LoadAnimation requires the Humanoid object to be a descendant of the game object 

1 Like

Is that char var assigned? I suppose you are not showing that, fix this first I guess

local Hum = char:WaitForChild("Humanoid")

1 Like

I don’t think that’s the issue because I have been using strings without brackets for a time and it’s fine.
Provided the complete code above.

2 Likes

I see, I didnt know that was possible. I only use it like FindFirstChild("Something")

1 Like

I tested ur script, by adding a wait at the beginning. I got no errors.
Probably the Humanoid is not created yet when u try to use it?

1 Like

It was working fine a while ago… I will try it using wait. Plus, I don’t think that should be the issue cuz I am waiting for humanoid. It cannot trigger if Humanoid hasn’t loaded.

doesn’t work for me, error only occurs on resetting it works fine on first join.

1 Like

Where do you have this script stored? If it is in StarterPlayerScripts, try putting it in StarterCharacterScripts.

It’s inside a tool. And it’s a local script.

So you want the animation to run when the tool is equipped or used?
You said it was working before. What changes u made?

There are two tools. I made the animation priority to action. But the other animation which wasn’t changed still shows this error and didn’t show before changing priority of other animation.

Used. Rest code is fine. It errors here.

Proabably theres something else you are missing. Cause I used ur script to add an animation to the tool im making. Using an animation I own (cause I think other ppl anims wont work if you dont own them) And its working perfect… Your script has no errors

local A = Instance.new("Animation")
A.AnimationId = "rbxassetid://6000317872"
local Hum = char:WaitForChild'Humanoid'
local Anim = Hum.Animator:LoadAnimation(A)

local function bombAction()
	bombEvnt:FireServer(false)
	Anim:Play()
end
bombT.Activated:Connect(bombAction)

If you try the same after resetting it shouldn’t work. It worked for me too when I had fewer things in my game. Btw, adding a RunService.Heartbeat:Wait() on top of script fixed it.

resetting what btw? What u mean? The player dying? or a special reset feature on ur game?

I meant Player dying… thirtycharacterss

Yeah, when the player dies, or click reset button, causes lots of problems for me too, when the scripts run again even if you are using that plr.CharacterAdded:Wait()

So I used to based this things on events that happens to connect things again. Or the easy/wrong method of adding some wait just for testing.

I would suggest check when the player despawn to manage the connection of the Humanoid to the animation.

Edit: @lagnis7859
I totally agree with you: “Roblox should fix issues like this”
But tbh, I dont know if we are doing something wrong… Cause you could add some if statements, and retry that connection, which Im so lazy to do… So the cheap way is the wait, and event based is more trustable

Fixed by adding a wait() above. Works perfectly but shouldn’t be required. Roblox should fix issues like this. It shows Humanoid not valid member of game when I am waiting for it…

1 Like

I had the same freaking issue! It breaks after the update I don’t know why… It work’s perfectly fine without in the tool.