Hey, I’ve been making a one piece game and specifically devil fruit abilities.
The thing is, I’ve always thought that the effects would be server-side and can be seen by other players.
I use localscripts for my devil fruit combat tools and when the player presses the move button then it requires a modulescript for that move. The problem is that the effects don’t appear for other players…
Does anyone have another way around this? I feel like modulescripts are better than remote events…
Module scripts are just functions stored in a table. It doesn’t replicate across the server-client boundary making it so if required by a local script any functions will be executed on the client.
You can mix modules and remove events. What I do for stuff like this is a single module in ReplicatedStorage, which has every attack as a function of the module.
Inside each function, I use RunService to check if its being called from the client or server with :IsClient() and :IsServer(). If its on the client, I do all the VFX and everything visual, on the server, I do hit detection and damage.
Whenever you want to do an attack, you use a remote event to fire to the server, the server will then activate the module function of the attack, and send a remote event to every player using :FireAllClients() which will activate that same module function.
The module function attacks will need an argument which tells the player that originally activated the attack, that way it can position it at the original player’s character.
If you use the position of the character on the client instead of giving it to the client from the server, every player will see it a bit different, but more accurate. If you use the position of the character on the server and give it to every client, every player will see the same thing, but it might be a bit inaccurate.
Well yes, but theres no other way for Client > Server communication except RemoteEvents and RemoteFunctions. You’d have to think about security when using remotes.
Yes, you just need to make sure you sanity check your remotes on the server. Sending less info from the client is also helpful, the best thing for this would be to send the key pressed or the ability slot being used, not the actual name of the ability, that way the exploiter can only fire what slot they use, not what ability they use.