How do I add an animation onto my NPC?

So, I know this is something simple but I’m no scripter of any sort, I made an animation and I want it to play on my NPC. How would I do it?

after you’ve created animations, make an Animation object inside the NPC and insert the ID in AnimationID

you would have to load the Animation from Animator through humanoid before using it in an events provided by instance or run it from functions.

local NPC_dir = script.Parent --indicates the script is in NPC
local humanoid = NPC_dir.Humanoid --Get humanoid from NPC
local anim_pak = NPC_dir.youranimpathdirectory --parent it to your instance name e.g if named "idle" it would be NPC_dir.idle

local idle = humanoid.Animator:LoadAnimation(anim_pak) --load the animation
local function play_on_init() --custom function, call it once created
   idle:Play()-- play the idle, MUST LOOP IF YOU WANT IT TO REPLAY
end

play_on_init()

if animator doesn’t exist, create one inside Humanoid of the NPC.

1 Like

What does “play_on_init()” do?

This basically runs the function when created, after loaded the anim it plays the animation.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.