How Do I Loop An Animation

How do I make an animation loop forever using a script?

I tried this but nothing happens in game.

local animation = Instance.new("Animation")

animation.AnimationId = "https://www.roblox.com/asset/?id=6243308493"

local AnimationController = script.Parent:FindFirstChild("AnimationController")

local animationTrack = AnimationController:LoadAnimation(animation)

animationTrack.Looped = true

animationTrack:Play()
6 Likes

you will want to go into the animation editor and turn on loop animation and the script you have made doesn’t work because you have to load the animation into the Humanoid.

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/assets?ID=6243308493"

local loadedAnimation = script.Parent:FindFirstChild("Humanoid"):LoadAnimation(animation)
loadedAnimation:Play()
3 Likes

It’s actually a lot simpler when you think!
In the animation editor just click the button that has a arrow circling a play button then export and animation and boom
If you want to stop the animation wihotur having to change it in editor just use

Animation:Stop()

1 Like

I think you should do:
player.Humanoid.Animator:LoadAnimation(animation)

In this case, you loaded the animation into AnimationController.
c461ddcf79eb68dfd679da3ec1c43e0f

You also set the AnimationId to a link. You must only set it as the ID of the animation.

1 Like

Follow these steps to loop an animation:

  1. Go to the AnimationEditor and load the animation
  2. Click the loop button next to the rewind/fastforward
  3. Export the animation
  4. Make a script in the NPC of choice
  5. Enter this script
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/assets?ID=6243308493"

local loadedAnimation = script.Parent:FindFirstChild("Humanoid"):LoadAnimation(animation)
loadedAnimation:Play()
1 Like

You should call the property that will loop the animation after it plays.

AnimationTrack:Play()
AnimationTrack.Looped = true

I was able to get an animation to loop by adding a script to the rig in the workspace, then in the scripts properties set the RunContext to Client. I used the following code.

task.wait(5)
local waveAnim = script.Parent.Animate.wave.WaveAnim
local hum = script.Parent.Humanoid

local animTrack = hum:LoadAnimation(waveAnim)
animTrack.Looped = true
animTrack:Play()
1 Like