Animation not playing?

Hello!

I am relatively new to animation in Roblox studio, and I am having difficulties playing my animation.

When a remote event fires from a client, an animation is supposed to run. This is my server-side script:

game.ReplicatedStorage.PlayerEvents.PlayAnim.OnServerEvent:Connect(function(player,animationID)
    local animation = Instance.new("Animation")
    animation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID

    local loadedAnimation = game.Workspace[player.Name].Humanoid:LoadAnimation(animation)
    loadedAnimation:Play()
end)

I know for a fact that the event runs because when I add a print() it works.

If anyone can tell me what I am doing wrong, that would be great. Thanks!

3 Likes

Can you show me the output? There may be an error.

Thanks for the reply! No there isn’t any errors, only that the animation doesn’t play.

I am not sure why that’s not working.

But try just playing the animation locally, for player characters the animation will automatically be replicated through the server and everyone will be able to see it.

Maybe that’s the error.

Is the animation uploaded to your account/group?

The animation needs to be uploaded to the holder of the place to work.

It still doesn’t work, but could the animation itself be the problem? Like if it didn’t render properly?

As @EntryRoot said it may be because it’s not your animation (although I don’t think that’s the reason)

Maybe you’re using a single frame animation, by any chance can you show us the animation while it’s in the animation editor.

Recently, Roblox has made some changes when playing animations.

Also, I’m not sure why you are using a remote event to play animations, as exploiters I believe could pass any animation ID through that animationID parameter. I would just play the animation on the client, as it still shows the animation to every player.

I would also take a look at this post: Humanoid:LoadAnimation Deprecated

Have you set the animation’s priority high enough? When in the editor there’s 4 priorities, from core (lowest) to action (highest).

Also just like @1Urge mentioned, you should write Humanoid.Animator:LoadAnimation.

1 Like

Oh now I got something! The animation plays but I think it’s playing at the same time as the ‘Idle’ animation. Any way to stop that? Thanks :smiley:

Oh no need to stop the idle animation! You can simply set the other animation’s priority above idle priority, they will both play respecting the priority list.

Oops I totally forgot about animation priority.
Use animationtrack.Priority and set it to enum.animationpriority.action

Epic! I changed the priority to action like some of you said and replaced Humanoid:LoadAnimation() with Humanoid.Animator:LoadAnimation() and everything works perfectly. :slight_smile:

Thanks for all the help!

4 Likes