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

Small help with animation not playing?

I just created my first animation and I wanted to test it. I'm currently testing it in an NPC. This is the script im using:

anim = script.Parent.Animation
aCon = script.Parent.AnimationController
animTrack = aCon:LoadAnimation(anim)
while wait(4) do
	animTrack:Play()
end

but the animation doesnt play. Any idea why?

1 comment

0

This is a server script

1 answer

✓ Accepted answer

I don't think it's a good idea to use a server script to play an animation for your NPC. You should have a regular script inside the NPC to play the animation for the NPC. I'm not too familiar with animation control, but another way to play an animation for an NPC is to load the animation to the their Humanoid.

This is a regular script inside the NPC

anim = script.Parent.Animation -- Where the animation is.
aCon = script.Parent.Humanoid --Where the NPC's Humanoid is.
animTrack = aCon:LoadAnimation(anim)
while wait(4) do
    animTrack:Play()
end

5 comments

0

Server script = normal script and ,if i'm not mistaken, loading the animation to the humanoid is for player animations

0

It works for NPC's too I did it in my game.

0

Your NPC must have a HumanoidRootPart to play an animation

0

You are right, just tested it. Many thanks!

0

;)

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