NPC Animation won't loop

Hello, I’m creating a script where a NPC will display an animation always, but it won’t loop. It just plays but never loops.

I’ve searched in the Developer Hub for a solution but it just shows how to play and not loop, or it’s for the player and not a Non-Player Character.

This is the script I am using:


local Seated = Instance.new("Animation")
Seated.AnimationId = "rbxassetid://4895897244"

local animController = Instance.new("AnimationController", script.Parent)
 
local SeatedTrack = animController:LoadAnimation(Seated)
 

SeatedTrack:Play()
SeatedTrack.Looped = true

How do I loop the animation?

3 Likes

You can loop the animation in the editor and do it that way.

I did it, but what I want to do is in-game, I saw other topic and it said the same, but it didn’t work.

Try moving the Looped segment above the play code. According to the documentation, Looped will wait until the track is finished playing to update.

1 Like