LoadAnimation error while Humanoid Object is present

Hello Developers,

The script below is a certain function in a modulescript that loads an idle animation after being called from a localscript to do so.

The issue is that the print i used to identify if whatever the first argument being passed in the function is a humanoid object or not, it fires but :LoadAnimation() still errors on the line i put the full error’s name on.

Even though there are a lot of topics on the :LoadAnimation() error, those methods of finding humanoid revolve around waiting for it to load after the character loads with :WaitForChild(“Humanoid”) or repeat loops but i could not find any topics similar to :LoadAnimation() on a Humanoid object being passed through an argument into a modulescript

The modulescript function:

function AnimationModule.LoadIdle(Humanoid,Tool)
	if Humanoid:IsA("Humanoid") then
		print("Humanoid Detected")
		local Animator = Humanoid:WaitForChild("Animator")

		if Animator then
			Idle = Animator:LoadAnimation(idleanim) -- LoadAnimation requires the Humanoid object (PlayerName.Humanoid) to be a descendant of the game object

In the localscript used to call the function there is another humanoid print that does fire when the humanoid object is present in the localplayer’s character and is used as the first argument.

Your problem is that the Humanoid isn’t a descendant of game which means its most likely parented to nil, Just print the Humanoid’s parent to debug it.

Or you could just change the already existing Idle animation inside the animation script.

char.Animate.idle.IdleAnim1.AnimationId = idle_id

Used :GetFullName() to print the directory of where the humanoid is. It only prints “Brehbrehhh213123.Humanoid”, why is that?

Because it’s parented to nil. Try putting

if not Humanoid:IsDescendantOf(game) then
  until Humanoid:IsDescendantOf(game)

Above :LoadAnimation


It just waits infintely, when i pass the character as an argument and use a for loop to reiterate through the characters children the Humanoid is there but it doesn’t print it as “workspace.PlayerName.Humanoid” it prints as “PlayerName.Humanoid”

Have you tried printing the value of its parent property?