NPC loop animation help

I have an NPC that I’d like to have loop an animation, but I don’t know how to make it do so? I tried making a script, but either it was wrong entirely, or I was putting it in the wrong part of the NPC or it was the wrong type of script, I’ll put the script I used below. I’d like to know 1, if that script works, and how I could improve it. 2, where to put it in the NPC, and 3, What type of script to use (I originally had it in a regular script)

Thank you, and Happy New years! :two::zero::two::four:

local AnimationId = --the ID

local Animation = Instance.new("Animation")
Animation.AnimationId = ("rbxassetid://%d"):format(AnimationId)
local AnimationTrack = script.Parent.Humanoid:LoadAnimation(Animation)
AnimationTrack.Looped = true
AnimationTrack:Play()
1 Like

You could just do

local id = Id

local Animation = Instance.new("Animation")
Animation.Parent = parent
Animation.AnimationId = "rbxassetid://"..I'd

local Track = script.Parent.Humanoid.Animator:Load animation(Animation)

Track.Looped = true

Track:play()

Thanks, I’ll try that. Where in the rig should I put it?
image

1 Like
local id = "123456789" -- copy your animation's number ID

local Animation = Instance.new("Animation")
Animation.Parent = parent
Animation.AnimationId = "rbxassetid://"..Id

local Track = script.Parent.Humanoid.Animator:LoadAnimation(Animation)

Track.Looped = true

Track:Play()

Put This script under the Rig, also you need to set the animation property to movement or action, (movement if you want walking loop animation, action if you want to loop anything else)

1 Like

Would the “Idle” animation be action then? Thank you for the help, I think this will work.

1 Like

no, Idle animation will have “Idle” as animation priority

(doing it as idle is better because there can be any other animations added to the same rig with same priority which can make animation broken)

1 Like

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