I am making a weapon system that has a trail that activates every time that you swing and deactivates when you aren’t swinging.
I have heard that visual effects should always be handled on the client, but if I have around 20 people playing in a server, swinging about twice per second, that would be a LOT of remoteevents firing every second. Firing to turn on the trail for every client as well as firing to turn off the trail.
So it seems that I have 2 options:
on the swinging player’s client, I fire a remoteevent to a serverscript. That serverscript will then fire all clients to turn on/off the trail.
on the swinging player’s client, I fire a remotevent to a serverscript that simply turns on/off the trail
I am currently using the first option to handle visual effects for abilities, but because swinging weapons happens at a much faster rate than abilities, I am worried that there will be issues.
It’s more performance efficient to go with the second method. Everything that the server affects is automatically replicated to all clients. You’re just creating unnecessary steps with the first method by getting every client to activate/deactivate the trail themselves.
Your weapons shouldn’t be coded using a local script in the first place because if it needs to access something on the server it would need to fire remoteFunctions.
As someone who has already made sword combos (Image below), I always use scripts as they function much better and make interaction with the environment much easier to code. I recommend you rewrite your code so it functions in a normal script rather than a local one.
This was coded entirely using a server sided script.