i’m trying to make a weapon that has quite some fancy animations, but i was told that one should put all animations and visuals client side and handle important stuff server side (like damage). what i’m wondering, however, is how i would go about firing to all clients to replicate the animations, mainly, the objects such as parts. could someone explain this? (i know it involves remoteevents but i don’t know very well, i mostly know server to client but not client to client)
When you play an animation on your character on the client, it is automatically replicated. No need to handle that yourself.
If you create the actual animation object with the server, then load them and play them on the client, they will be replicated.
I have has this issue countless times while animating and this seems to solve the issue every time. Just put the animations inside whatever script you are using, then when you play the game and load them and play them on the client it will replicate!
not animations specifically, i meant more about stuff like the objects (parts, particle emitters) that don’t automatically replicate
Ah. Basically what you should do is this: whenever a client wants to do something that involves a visual such as particles, first let that client create their own visuals, so there isn’t any latency. Second, have that client tell the server that they are requesting other clients to render visuals on their character or whatever. The server should then fire every client other than the one requesting the visuals. The only thing the server should tell the client is which Player requested visuals. All clients should be listening to an event, with the listener poised to create effects on their own clients. Obviously I haven’t taken security into account with this, but that’s the jist of it.
You could animate them for every single client separately or just animate it using the server.
If you don’t know how to animate parts then you can consider reading this article about AnimationControllers.
it made sense until the server telling others part. could you explain how i would approach this. would it be like a built-in local script in starterplayer that loads objects according to the data the remote event sent over?
Here’s how I would do it. The same LocalScript that fires the RemoteEvent should also be listening to that RemoteEvent for ClientEvents. The only variable for the listener function should be the player (or character) to render the effect (or effects) on. The server, when the event is fired, will then :FireClient
every player except the one that requested effects. It’s all up to you though, and there isn’t really one solution that works for every case.
I would recommend using an event
For example let’s say this person clicks this GUI I button
anim1Event:FireClient()
That’s how I would put it
But you must make a script in server storage and make sure you put your animation script in it.
You should use events more because client sided tends to only work in studio.