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

Animation not looping Properly?

Hi I'm writing this game which requires animations for the npcs. I have stuff where I want the animation to loop forever. I'm not sure why but it only plays once and then stops. If I run it (not like with player. just running it) it works fine. I have a local and non local script that are duplicates and it doesn't do anything.

Code:

local Humanoid = script.Parent:WaitForChild("Humanoid")
local animationTrack = Humanoid:LoadAnimation(script.NPCIdle) -- The animation is in the script

animationTrack.Looped = true
animationTrack:Play()

1 comment

0

did you turn the looping option on in your animation editor? also please do not ask the same question multiple times

1 answer

So if you did turn on looping and it didn't work then a method that I have come to use which works would be something like this.

local Humanoid = script.Parent:WaitForChild("Humanoid")
local animationTrack = Humanoid:LoadAnimation(script.NPCIdle) -- The animation is in the script

while true do
animationTrack:Play()
wait(animationTrack.Length)
end

That's not the most optimal way of doing it but that will allow it to function. If That does not work for you then I'll make sure to take this answer down.

2 comments

0

I just ended up writing a local script in the starterplayerscripts and it works fine

0

Alright sorry for not being able to help.

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