Help Playing Animations

Hello I have followed the wiki and placed the following code inside StarterCharacterScripts:

local Players = game:GetService("Players")
local character = Players.LocalPlayer.Character

if not character then
    character = Players.LocalPlayer.CharacterAdded:Wait()
end

local humanoid = character:WaitForChild("Humanoid")

-- Set it up
local testAnimation = Instance.new("Animation")
testAnimation.AnimationId = "rbxassetid://28156501"
local testAnimationTrack = humanoid:LoadAnimation(testAnimation)

-- Play it
while true do
  print("Animation Looped")
  wait(2)
  testAnimationTrack:Play()
end

This should play the animation every 2 seconds or so, and it does not. The print does output of course.

The animation ID is just a free animation by ROBLOX, found here: punch - Roblox

Anyone know why this wont play?

1 Like

I’m unsure on the reason as to this occurrence; however, you can try the following:

Have you experimented with a different animation in which you own? It is crucial that you’re the one who owns the animation and it is owned by either yourself or published into any group that the game is found in.

If it still doesn’t work with an animation of which you’ve made, then please reply and I’ll try to help you sort the issue.

Have you tried changing the Priority feature of an AnimationTrack to Enum.AnimationPriority.Action?

The animation is most likely compatible with R6 , try making one yourself if you want your game to be R15- only.

There are a couple reasons for this:

  1. Animation Priority is potentially below movement and as such, when you move it’ll be unable to play. This is unlikely however as it is an animation made by ROBLOX, but do check this.
  2. Have a look at whether the animation is compatible with R6 or R15. Given the ID is much younger on the animation, I can only presume that the animation might not work with newer rig types because it’s been designed for the older types.
  3. As the “ROBLOX” account owns the animation, you might have to publish it under your account or group, and set the new ID to the animation id in your script. This was implemented a while back as a security feature.

Let me know if you need any other assistance. I tried doing the animation on both R6 and R15 so I can only really properly suggest the bottom one as the potential cause.

One question: if your script is in StarterCharacterScripts, why are you indexing the character in such an awkward manner? Just do

local Character = script.Parent

Scripts in this container are cloned into the character once it’s added, so the Character should be immediately available to any scripts placed here. The whole top part does not need to exist.


@pp2w @Mariofly5 All assets owned by Roblox can be used by developers, so asset ownership isn’t relevant in this case. The asset ownership security measures only pertain to user-created assets. There’s a reason why Animation Bundles, catalog tool animations and such work across any game, it has to be there. If developers were blocked from using Roblox animations, things wouldn’t appear as expected.


This script has nothing inherently wrong with it, so the only thing I can think of is the compatibility of this animation with your rig. Another thing might be that you’re creating a animation instance on the client but I almost doubt this is relevant. That raises a question though: why have the script create the animation instance when you can just add it as a dependency for the script (child)?

1 Like

Thanks, I just copy/pasted the script from the Roblox wiki for expediency, its probably not how I would have written it.

1 Like