"loadanimation requires the humanoid object to be a descendant of the game" no, i have searched every post and tried out every solution but none of them worked. is there other ways i could fix this solution? this only happens everytime i respawn.
stuff breaks when respawns?
1 answer
Issue
"loadanimation requires the humanoid object to be a descendant of the game"
Solution
Solution is pretty easy if you know what the error is saying. It is saying that you can not load the animation because the Humanoid object of the character is not a Descendant (child's child in a recursive manner) of game.
There is a method called IsDescendantOf which is a member of all Instance datatypes.
https://developer.roblox.com/en-us/api-reference/function/Instance/IsDescendantOf
This means you can yield the thread until the Humanoid is a descendant of game; humanoid:IsDescendantOf(game)
This could look something like:
Where humanoid is reference to the Humanoid you want to load the animation into, and where animation is the Animation instance that is going to be loaded into humanoid.
A repeat until loop repeats a block of code until the condition is met. The wait() is there so the game does not hang forever (basically crash; crash occurs because lua is single threaded and a length loop with no yield will take up the entire thread causing the entire client to freeze).
repeat wait() until humanoid:IsDescendantOf(game)
humanoid:LoadAnimation(animation)
This discussion is preserved as it was. New answers, comments, and votes are closed.
