Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I get my NPC to use an animation on repeat?

I have tried everything I can think of so if anyone can help me I would be grateful

3 answers

✓ Accepted answer

First, when making your animation, make sure it has the loop setting on so it plays continuously.

Instructions:

Place a server script inside of your NPC model

Inside of that server script, place an animation and set the animation ID

Now enter this code into the server script:

local humanoid = script.Parent:WaitForChild("Humanoid")
local animation = script.Animation -- Place Animation with set AnimationID inside of the script

local playanimation = humanoid:LoadAnimation(animation)

playanimation:Play()

If anything goes wrong please let me know.

Hope this helped!

3 comments

0

Ok I will try it out sorry for not seeing this quickly

0

tysm it worked!

0

No problem! Glad i could help

When making a animation after you saved it click on the animation and click Looped

4 comments

0

so I don't need a script

0

by saving i meant when you get the instance click on it

0

yes you dont need a script

0

What Puppynniko said first was true but, you do need a simple script to make it run for the first time.

When using loops in animations it isn't required to use the Animation Editor. You can also use basic code for it.

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator") --You should also use Animator in the Humanoid as LoadAnimation is deprecated on the Humanoid Itself for FE Patch.

local Anim = animator:LoadAnimation(AnimationPath)
Anim.Looped = true

Anim:play()

This discussion is preserved as it was. New answers, comments, and votes are closed.