How to play an animation?

How do I play an animation? I mean by having an animation item into a tool, but what code do I write inside the script I want it to be able to play the animation?

There are numerous tutorials on how to play animations with tools. You should search for what you are trying to do before posting. Make a tool play an animation

Hi asunoandkrito!

I suggest reading up on animation objects on the developer wiki. The main point is that you create an animation object, load that object through the character’s humanoid, and then play the loaded animation. A snippet of the wiki example is below.

local animation ="Animation")
animation.AnimationId = "" -- Roblox dance emote
local animationTrack = humanoid:LoadAnimation(animation)
1 Like

It’s pretty much only a few lines of code, but there are a few key things you need to pay attention to:

pre-step inside the script: local animator = humanoid:WaitForChild(“Animator”)

It’s really preferable to create the actual animation object from the script from the get-go, but you do not have to do it.
~If you have already created an Animation object in the explorer and have set the ID, you can skip steps 1 and 2.

  1. local Animation =“Animation”)

  2. Animation.AnimationId = “rbxassetid://5432167890”

either way, you will have to do step 3, you must LOAD the animation in the same script you want to play it in.

    • “Load” animation onto the animator

local Animation = animator:LoadAnimation(walkAnim)

    • And finally, the last line of code you can place wherever you want after you’ve created the animation:


It’s just like a Sound. I hope this helped.