Animations not replicating

My problem here is that animations don’t always seem to replicate when they should to other clients since I am using normal Roblox animations. I thought this my have something to do with my rig where when a player’s character loads, I make a minor adjustment to the arms for a small custom rig, but even default animations don’t even replicate sometimes and I have no idea why.

Sometimes the animations replicate sometimes they don’t, and I have no idea why. I really need some help on this.

3 Likes

The best way to get around this weird replication issue is to do the following:

  • Run the animation for the player on the client
  • Send remote event to server to tell what animation is being played
  • Server verifys this and sends the animation to all other clients
  • Every other client plays the animation for the original player

Basically, the client tells the server to tell the other clients to play the animation on their side to complete the “replication”.

While there will be delay due to remote events, it’s about the same as if replication worked properly. Just be sure that the client can’t spam the remote event, or that opens up the door for exploits.

1 Like

I’m trying to avoid this, I really don’t want to force myself to do this, but I might have to if I can’t find any other solutions.

1 Like

The issue is that client → server only works if the animation is created on the server. And sometimes, it only works if the server plays it. Animations are really weird because they change the Motor6Ds of characters, which don’t automatically replicate. I suspect that there’s some kind of edge case were the animation just doesn’t replicate.

2 Likes

Given the animation is loaded via a player character (not an NPC): you should ensure any animation is loaded locally (via your tool script) after you make sure the animator object for the character has replicated to the server.

The animator is a child of the Humanoid which ensures that animations can be loaded and played locally, while still replicating to a reasonable degree of fidelity.

That way any client side animations that are loaded via the owning client should replicate as naturally as the vanilla walk animation.

As per your current case, based on your information, I would ensure you are altering the existing rig on the server rather than the client to ensure that any animations that play are not dealing with desync between the client side version and the servers version of the same rig.

If you alter the rig via the client, even a little bit, the server won’t realize the change, and when the animator attempts to replicate the animation, the joints will be different than what the server (and thus every other client has…)

Shouldn’t be too difficult to fix, good luck!

The animations are created on the server. Maybe, it has something to do with me enabling/disabling Motor6D’s on the server when a weapon is equipped/unequipped on the server?

The rig is never altered on the client. The server is the one enabling/disabling the motor6d’s for the rig, and is also the one that creates the animations for the client to load.

Sometimes there’s replication, sometimes there isn’t.

It seems like it’s a desync issue caused by the rapid change in rig when you switch tool. When you change your tool, the server only detects that after it travels from your client with a delay (IE your ping).

Since you’re changing tools so rapidly, the server is rapidly changing the rig at the same time as receiving another countermanding request to change tool and thus change the rig again.

I would ensure the rig is static; Don’t change the rig, change the static animation (you can even use the same animation/pose to keep it simple).

Since an animation would be done locally, and replicated naturally. It will be reactive enough to look good but reliable enough to avoid desync since the client has the absolute authority over the animation state of it’s character.

You need not create the animations on the server, I would recommend you try to load the animations locally and make sure they are played locally as to avoid any conflicts between the authority of the player and the server when it comes to animation replication.

This should alleviate the problem. Best of luck!

The issue of not replicating properly generally happens more often when the client spam equips when they spam equip/unequip their weapons.

Also each weapon has it’s own animations so i have to change the Motor6D that the weapon is attach to with different models.(i.e. I animated the weapon itself too)

Here’s a photo of the setup.

The arms are attach to an invisible part so that way I can rotate that part with its Motor6D C0 property and the animation will still play when the player goes into ADS.

If you want to animate the weapon, and animate the character at the same time. Rely on the simple handle weld of the tool, keep the rigs separate, and just animate them respectively on the client.

This will ensure that no matter the difference on the client and the server, there is no different being created in rigging, just a difference in which animation is playing.

The reason for the desync is because dynamically joining and disconnecting two rigs between your character and the gun needs time to occur on the server, and it cannot react quickly enough between the frame-by-frame switching of tools. If you give it time to change, and do it in a highly reliable fashion, you’ll be fine, but otherwise keep it seperate.

In my experience, I developed a standalone handling system for this very use-case because tools are less reliable than I needed them to be.

That’s probably the simplest explanation I can offer, it’s a tough problem.

How do I know the amount time it needs to change?

Your solution for timing should be dependant on how you change the rig via the server.

I would just ensure that nothing is ever working on outdated information, perhaps run a bit of logic that before a tool changes the rig, that the tool is in fact still enabled, otherwise assume another script will change the rig for the latest tool.

I don’t use tools I have my own custom system I made to sort of replicate them, I manually change the properties of a custom “grip” Motor6D on the server when a tool is equipped/unequipped.