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

Animation not looping Properly?

Asked by 4 years ago

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()
0
did you turn the looping option on in your animation editor? also please do not ask the same question multiple times MegaManSam1 207 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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.

0
I just ended up writing a local script in the starterplayerscripts and it works fine sen_trix 31 — 4y
0
Alright sorry for not being able to help. deth836231 142 — 4y
Ad

Answer this question