Animation doesnt play

Hello, I have a problem with my animation. Here is a video that I just did, to showcase my problem.

I saw a few things.

  1. This does not appear to be your animation assetID (pulled from models, not “my models”). You need to personally publish the animation to Roblox to play it in game. You do that through the Animation Editor. While you are there, make sure this animation works on this model (r6 vs r15 issues). You may have done this step, but it’s not clear.
  2. To play an animation, you need a script. 2 lines, once you master it: LoadAnimation, and Play. I recommend starting with roblox’s code here:

Animator:LoadAnimation (roblox.com)
3. This last one is just an FYI. All the animation object does is store that assetID. You can reference it via code, or put it in code directly.

Let me know if you need more instruction past this. Happy to help! We need more animations in games!

so this is the id I got from the url 8460275094 I did publish it.

Can you give me the lines so I can just copy and paste? I dont know where I would put my id I got from the url

There are multiple scripts out there, but I will give you one that just needs the animationId. This is a modified script from AnimationTrack api.

Use a local script

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
local humanoid = character:FindFirstChild("Humanoid")

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=8460275094" --Id added here
local animationTrack = humanoid:LoadAnimation(animation)
--if something goes wrong, I add a wait(1) here.  LoadAnimation is not instantaneous
animationTrack:Play()

If this is a looped animation, you should see it. If it is not looped, you will want a fairly large wait, so that it happens after the game loads. Right now, you just want to confirm the animation works!

I did but it still doesnt work and my hair removes itself

The hair issue is something else. Animations don’t break hair.

Can you play the animation in animation editor? Something like this, so you can confirm the animation and avatar are compatible?

yes it does play in the roblox animator. However the hair doesnt seem to be moving

That sounds like the hair is not properly welded to the head. It’s not moving, and it’s falling off when you run the game.

1 Like

Here is a script to play the animation on the rig in the workspace.

This code should be used in a server script (regular script)

-- Put animation under this script so the script can access it easily
-- Put this script under a rig (character)

local character = script.Parent
local humanoid = character:FindFirstChildOfClass("Humanoid")
local animation = script:FindFirstChildOfClass("Animation")

if humanoid and animation then
	local anim = humanoid:LoadAnimation(animation)
	anim.Looped = true
	anim:Play()
	print("Played animation")
else	
	print("Could not run animation")
end

Make sure all the parts of the character aren’t anchored, and make sure you own the animation (it won’t play animations you don’t own).