Loading Animation Not Working

Hey guys, I am making a game which uses a skinned mesh as the main player character. I made a couple of animations for it in blender. I imported them into Roblox correctly, since I can see it work in the Roblox Animator plugin. But when I try to load it, it doesn’t load at all. I also tried printing the animation length, which resulted in a zero. I really did export it correctly, so I have no idea what the problem is. Please help me!

2 Likes

You mean when you load the animation in a script? Or do you mean something else? If you are trying to load the animation in the script, could you please show your code?

Well I tried loading it in a very simple script, but it doesn’t work either. Here’s the script:

local anim = script:WaitForChild(“Animation”)
local animLoad = script.Parent:WaitForChild(“Humanoid”).Animator:LoadAnimation(anim)
animLoad:Play()
animLoad.Looped = true
print(animLoad.Length)

1 Like

This is wrong

script.Parent:WaitForChild("Humanoid"):LoadAnimation(anim)

LoadAnimation() for Humanoids are deprecated, so he isn’t wrong

Try this:

local anim = script:WaitForChild("Animation")
local animLoad = script.Parent:WaitForChild("Humanoid"):LoadAnimation(anim)
wait() --for a split second the animator's id is empty
animLoad:Play()
animLoad.Looped = true
print(animLoad.Length)

Also a tip: if the script is called on a player’s character, then make sure it’s a LocalScript, otherwise if it’s an NPC, you can use a regular script.

I’m testing it on a npc, so I’m using a normal script. What does the “path.to.anim.instance” mean tho?

The location of your animation’s instance. For example if it’s inside the NPC’s character:

script.Parent:WaitForChild("Animation")

Edit: nevermind I just noticed that there’s a variable for that, I updated the original script

It still prints 0 and doesnt play :grimacing:

Edit: It now prints 0.75, but doesnt play