Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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

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' QuikSilver09 5 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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?

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) QuikSilver09 5 — 5y
0
Essentially, but it seems like roblox is ignoring it. So adding an extra check shouldn’t hurt. APointProven 80 — 5y
Ad

Answer this question