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

LoadAnimation requires the Humanoid object to be descendant of the game object?

error : LoadAnimation requires the Humanoid object to be descendant of the game object


local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Plr)
Plr.CharacterAdded:Connect(
    function(char)
		print(char)
        local Hum = char:WaitForChild("Humanoid")
		print(Hum)
        Hum:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
		
	    DeathAnim = Hum:LoadAnimation(script.Parent.Reset)

        Hum.HealthChanged:Connect(
            function()
                if Hum.Health <= 0 then
                    DeathAnim:Play()
                end
            end
        )

        DeathAnim.Stopped:Connect(
            function()
                Hum.Health = 0
                Hum:SetStateEnabled(Enum.HumanoidStateType.Dead, true)
            end
        )
end)
end)

Gives error. Char > my username char.Parent > nil how to wait for character happen in workspace dont know, wait() on start somehow stops script

EDIT : you need to wait for character to appear in workspace, char.Parent is nil so humanoid isn't in game object, cant load animation, how to fix that idk

2 comments

0

whats the error?

0

The error is that she/he didn't insert a cooldown for the humanoid to load in.

1 answer

✓ Accepted answer

Try putting a wait(2) after the CharacterAdded function to wait for the character (which contains the humanoid) to load in.

6 comments

0

Its not going to make it work. bcuz HE is litteraly waiting for the Humanoid to load

0

don't you see Char:WaitForChild("Humanoid") ?

0

I did

0

But Char:WaitForChild("Humanoid") isn't working

0

But Char:WaitForChild("Humanoid") isn't working

0

Oh and I got it right. :)

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