I try make the animation on rig R6 ( from roblox rig builder ) but it wouln’t work.
local AnimationId = "913376220" --//Put in the id here
local Character = script.Parent
local Humanoid = Character.Humanoid
local Animator = Humanoid.Animator
local Animation = Instance.new("Animation")
Animation.Parent = Animator
Animation.AnimationId = ("rbxassetid://%d"):format(AnimationId)
local AnimationTrack = Animation:LoadAnimation(Animation)
AnimationTrack.Looped = true
AnimationTrack:Play()
First you have to make sure you are allowed to use this animation:
Next, you have to load the animation onto the Animator
should be
Animator:LoadAnimation(Animation)
Lastly, we have to wait for the animation to be loaded in before playing it.
One way which maybe may not always work is to just stick in a task.wait() after that line.
Your final code should be something like
local AnimationId = "913376220" --//Put in the id here
local Character = script.Parent
local Humanoid = Character.Humanoid
local Animator = Humanoid.Animator
local Animation = Instance.new("Animation")
Animation.Parent = Animator
Animation.AnimationId = ("rbxassetid://%d"):format(AnimationId)
local AnimationTrack = Animator:LoadAnimation(Animation)
task.wait() -- Something that waits until the animation loads
AnimationTrack.Looped = true
AnimationTrack:Play()