Animation suddenly stops playing randomly when in server

My issue is what the title is pretty much. I am using server sided, non-local scripts, for the programming. I am a bit confused about local scripts too and I have a few questions about them:

  • If the animation is in a local script how does everyone else see it?
  • For my game the speed of the animation is very important, so I have to tweak the animation speed during play, how can I trust the client with this, since I have to play the animations through a local script, do I have to go to the effort to get all running animation tracks from the humanoid etc and do it that way each time?

My main issue is that an animation I want to play for when a player is ‘exercising’ in my game stops playing when I test it out in a server. It runs perfectly fine when in studio. The reason I am asking about playing animations locally is that I think this could be a solution, however it seems extremely hard to convert to this and coordinate everything in the same way.

Some photos:

In studio it runs fine:
image

In game it works for a short while (a few seconds or so), then the player just goes into its idle position.

Like so.

This problem has bugged me for a while, I’ve tried changing priority and disabling the default animation script in the player to stop it from overriding, but nothing seems to work.

The animation is not looped, I play it again and again each time it goes through a cycle of doing one exercise, eg. one push up.

Just wondering if anyone has any suggestions or has experienced this sort of thing before.

2 Likes

If you want it to replicate over look at Network Ownership over objects.
Playing the animation on the client side might fix the bug

First of all, good luck with your project!

I would suggest putting animation in ReplicatedStorage and playing animation from LocalScript. Then, making animation a loop. Keeping AnimationTrack(It is what you receive when you :LoadAnimation()) somewhere you know and stop when you need to. Looping the animation is much easier, and if you feel like when it is looped you might not know when animation is ended, you can name Keyframes and then keep track of them. Here’s an AnimationTrack event that could help you.

1 Like

Thank you for the good luck, and I’ll have a go at playing the animation through a local script in the players backpack with remote events. Thanks for the link too, I can clearly see now how the animations replicate.

I still find it all very bizarre because if animations can be played locally then it seems really insecure, what’s stopping exploiters from firing the remote event at random times during the game to try and mess with things, or even play their own animations which would then replicate to the server?

Okay, I started playing the animation on the player through using remote events, and now the same thing that was happening in the server now happens in studio too. So I don’t think it’s to do with playing the animation locally.

I’m going to try changing the animation to ‘Action’ on the actual animation file on the site, see what that does.

Ok turns out disabling the Animate script in character seemed to work, so if anyone else has an issue with this try doing that.

3 Likes

You shouldn’t have to do this if you uploaded your custom animation with a priority higher than Core (which is any other option). Occasionally in the past, some Roblox animation packs have been accidentally uploaded with higher priority animations in them, so if you find one pack in particular whose Idle animation interrupts things, please let us know!

3 Likes

When you call humanoid:LoadAnimation, the humanoid returns an AnimationTrack which will allow direct replication to the server when calling functions like :Play() and :Stop()

Yeah. You basically just create a remote and send the animationTrack as an argument