I have an accessory that attaches to the character (via BodyBackAttachment). That accessory has an AnimationController to animate the accessory. A local script within the StarterPlayerScript, starts and stops the animation.
The problem is that the animation only displays on the Client, and is not replicated to the server, so other players cannot see the animation.
Why is the animation only shown on the client, and not being replicated? What can I do to fix it?
Is the animation controller created locally? If so, the server doesn’t know it exists so animations won’t replicate. Also, for replication to work at all, you’ll need to give network ownership of the item to the player
The AnimationController is within an Accessory within a Character that is generated from a StarterCharacter, so the server does know the AnimationController exists. And since the Accessory is a descendant of the Character, the player has ownership of the Accessory.
That is what is so confusing. It seems like it should be replicating since all the conditions are met.
Is the assumption that a LocalScript will be able to play an animation and have it replicate to the server/other clients? My theory is that most actions caused by LocalScripts (besides remote events/functions) are not replicated to the server/other clients, even through controlled instance methods like a AnimationController’s Play() method. If this is correct, then using a RemoteEvent to send a signal from the client to the server would allow a server script to begin playing the animation and have it be replicated to all clients.
(Note: @DarkContinuum’s suggestion of making the items manipulated by the animation and the animation controller owned by the player may also fix it. If that works, I’d say it is a better solution.)
The issue is a result of how the AnimationController object functions, how it differs from the Animation object and how the AnimationController and Humanoid objects both cause (or don’t cause) replication differently.
An AnimationController is primarily used to substitute the Humanoid when creating an AnimationTrack when utilising the :LoadAnimation() method, allowing animations to be applied to any model. On the other hand, an Animation is loaded through a Humanoid object, also utilising :LoadAnimation().
The difference?
(In a nutshell) the characters positions inherently replicate to the server, so by utilising the LoadAnimation() on the Humanoid object within a user character from the client, the Animation will play on the client and the positions of the character will also replicate. (note this may not be exactly 100% correct however this is essentially the behavior).
The AnimationController does not replicate in the same way which the Humanoid/character does, in fact it doesn’t replicate at all to my understanding, so therefore the animation is not played on the server as the models position isn’t replicated to the server.
This can be visually demonstrated by the image I snapped, which displays the server and client besides each other while playing an Animation through an AnimationController every 5 seconds.
(you can see the animation isn’t replicating to the server)
note to anyone reading: not sure if I was 100% correct on every aspect of character replication, please feel free to correct me if I was wrong as it would greatly help the op and myself.
From the Wiki:
Important: You can not use a Humanoid and AnimationController on the same rig.
So having both an AnimationController and a Humanoid cause conflicts. In my case, having an AnimationController within an Accessory of the Character does not work properly since the Character has a Humanoid within it.
Also for future reference, whichever host loads the animation will be able to play it fine, but any client (and even server) where the animation is played prior to it loading, it will not replicate. (Examples: playing an animation and then someone joins, playing a new animation (on client or server) prior to it loading for everyone) When the animation finishes loading however the next time the animation plays it will replicate correctly.
You can only play animations if the NetworkOwner is yourself. Meaning the character model is in you or the HumanoidRootPart’s NetworkOwner is set to you.