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

[SOLVED] LoadAnimation requires the Humanoid object. How do I fix this animation loading error?

Whenever my character is reset, I get this error from my tool. Where am I going wrong here?

local character = player.Character or player.CharacterAdded:Wait()

player.CharacterAdded:Connect(function(newCharacter)
	character = newCharacter
end)

local hum = character:WaitForChild("Humanoid")

local IdleAnim = hum:LoadAnimation(Animations.Idle) -- This is the line erroring
local ReloadAnim = hum:LoadAnimation(Animations.Reload)
local ShootAnim = hum:LoadAnimation(Animations.Shoot)
local DrawAnim = hum:LoadAnimation(Animations.Draw)

LoadAnimation requires the Humanoid object (QuikSilver09.Humanoid) to be a descendant of the game object

1 comment

0

[SOLVED, kinda] I had a lot of people try to help with waits and stuff. It didn't work and I couldn't figure out why. I was using StarterPack, but for my scenario I spawn the weapon for them anyway and don't use StarterPack so it won'

1 answer

Since the issue is the script is trying to grab the old character and the old character is gone. I’d say changing local character to this:


local character = ((character and character.Parent ~= nil and character) or player.CharacterAdded:wait()

It should make sure the character exists first. Try that maybe?

2 comments

0

I will try it, but I figure that is what I was doing with this line already? player.CharacterAdded:Connect(function(newCharacter) character = newCharacter end)

0

Essentially, but it seems like roblox is ignoring it. So adding an extra check shouldn’t hurt.

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