Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago
Edited 2 years ago

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

3 answers

Log in to vote
0
Answered by 2 years ago

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!

0
Ok I will try it out sorry for not seeing this quickly Puppy_lovertheawsome 84 — 2y
0
tysm it worked! Puppy_lovertheawsome 84 — 2y
0
No problem! Glad i could help TabooAntonioiscool 42 — 2y
Ad
Log in to vote
0
Answered by
Puppynniko 1059 Moderation Voter
2 years ago

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

0
so I don't need a script Puppy_lovertheawsome 84 — 2y
0
by saving i meant when you get the instance click on it Puppynniko 1059 — 2y
0
yes you dont need a script Puppynniko 1059 — 2y
0
What Puppynniko said first was true but, you do need a simple script to make it run for the first time. AltairCelestia 47 — 2y
Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
2 years ago

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()

Answer this question