I thought animations replicate from client to server? Generally I would assume that the client should play animations, as it’s more responsive and performance-wise; it would be relatively smooth.
Its always better to play it on client to prevent lags (I guess) and since roblox animation replicate from client to server its always best to use it in client rather than server.
Animations should be played from a LocalScript if they’re running on a player. The method I most use to connect this is by using RemoteFunctions, so whenever I fire a RemoteFunction the LocalScript runs the animation and returns a value once the animation is complete. This way my ServerScript can know when an animation is over, it’s useful if you want to add effects at specific moments of animation.
Sometimes, I do use ServerScripts to play animations on a Humanoid, but that’s due to security. For instance, I’ve made a sword which can stun people, instead of making it so the sword fires a RemoteFuncton to the target player to make him stunned, I instead made it so the animation is played from the ServerScript which determines when the sword is touched. This way exploiters cannot fire the Remote and confuse players by making them play the “stunned” animation.
If you’re working with NPCs, animations should be run from a ServerScript using an AnimationController, multiple tutorials can be found around it.
Issues with ServerScript animations on a Player
Sometimes the animations can glitch out, especially if a player just joined the game and the animation happens to be running, the player who just joined won’t see it.
Server animations will sometimes be laggy or just not run smoothly because it relies on the user’s internet connection with the server.
Issues with LocalScript animations
Can be exploited fairly easy, exploiters can play animations and confuse players, which is not that big of a deal but it’s still something to consider.
LocalScript animations aren’t laggy and run smoothly since they rely on the Client and doesn’t require a good internet connection.
If you’re working with NPCs, animations should be run from a ServerScript using an AnimationController, multiple tutorials can be found around it.
Not necessarily, you could run the same animation on the AnimationController for all clients individually and avoid running the animation on the server. This would provide the same advantages as running any other kind of animation on the server as opposed to the client i.e the animation will run smoother relative to the client’s hardware/CPU capacity
The method I most use to connect this is by using RemoteFunctions, so whenever I fire a RemoteFunction the LocalScript runs the animation and returns a value once the animation is complete. This way my ServerScript can know when an animation is over, it’s useful if you want to add effects at specific moments of animation.
Also, didn’t quite catch this the first time I read your earlier response, but you should really avoid firing a RemoteFunction from the Server to the Client. This isn’t related to the thread, but good knowledge to know. The wiki goes more in depth on this subject and good practices with RemoteEvents/Functions:
No worries! Glad to help. I’m actually working on something similar atm, so I’ve been playing around with optimizing on movement/animation of humanoids.
While it isn’t 100% a terrible idea, anything that can be handled securely on the client, should be handled on the client. This:
• relieves the server from unnecessary work
• allows better feedback to players. Remote communications are not that instant; it takes time for some data to be transferred to the other side of the world. By having your logic directly located on the client, it’s possible to give direct feedback to the player and not wait a response from the server.
Is it worth it to fire :FireAllClients() Event to play the animations on every client?
I am trying to achieve a carry system and to check if the player is able to be carried I send a remote event to the server then play the animations, the one who sends the remote event is the client who is asking to carry. Moreover, should I just play it in server or do FireAllClients event.