Can't load animation into NPC?

Hello! I am trying to load an animation into an NPC:

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://6964312367"

local controller = script.Parent.Humanoid
controller:LoadAnimation(anim):Play()

The animation isn’t mine, the owner of the game I am working on made it though so it should work. Here is the explorer:
image

Can anyone help? Thanks for reading!

Can I know what is the output for your script.

Humanoid isn’t the controller for animation tracks. You’d need to create an Instance, Animator, then parent it to the humanoid - hence, use that instance for loading animation.

it should still work when you call :LoadAnimation() on the humanoid

If the animation isn’t yours or the owners then it wouldn’t play either way unless you re-export it and play it with that id

if the game isn’t published in a group, then the owner has to publish the animation themselves for it to play (only plays in a live roblox game, not in studio unless you’re the owner)

if the game is published in a group, the animation has to be published to the group, then both developers and owners will be able to see the animation regardless of whether they are in studio or ingame

:LoadAnimation() for Humanoid is deprecated - therefore, it’s strongly not advised to utilise it to assure that the animations won’t break in the near future, or now.

Animator:LoadAnimation() is the function you’d use, as mentioned beforehand.

1 Like
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://6964312367"

local controller = script.Parent.Humanoid.Animator -- You need to utilize the Animator in the Humanoid
controller:LoadAnimation(anim):Play()

Tried this and it still did nothing:

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://6964312367"

local controller = script.Parent.Humanoid.Animator
controller:LoadAnimation(anim):Play()

The game’s owner did publish the animation.

Insert the animation ID into the :LoadAnimation parameter, not the object.