Trying to add idle animation to NPC

Hello, I am working to add an Idle animation to Timmy (an NPC) but I can’t get it to work

Capture
The script named “Script” is the script I am using to try to make the animation play. The “Idle” under “AnimSaves” is the animation I am trying to play.

local player = script.Parent --The NPC model
 
local humanoid = player:FindFirstChild("Humanoid")
 
local animation = script.Parent.AnimSaves.Idle
 
local anim= humanoid:LoadAnimation(animation)
anim:Play()

This outputs the error “LoadAnimation requires an Animation object” and I can’t figure out how to fix this.

3 Likes

This is the script I use for NPCs.

local hum = script.Parent:WaitForChild("Humanoid") -- Find the Humanoid
local anim = hum:LoadAnimation(script:FindFirstChildOfClass("Animation")) -- It finds anything inside of the script that is "Animation" and loads it.
anim.Looped = true -- If your animation is not looped, you can loop it like this.
anim:Play()

Try putting the Animation under the script (then add the ID into it) instead of trying to locate it in the NPC itself.
For example;
image

4 Likes

When I started animating idle npc’s I used this video made by @Sheasu

This gives you all the information needed for it and it works well when I need it.

2 Likes

Idle is not an Animation Object. Make it an Animation object and insert your animation id.

5 Likes