I’m working on a battlesystem that revolves around server client communication.
Heres how it works:
User presses left mouse button → local scripts requests the move via remote event to the server → Server receives the message and checks if the user can use the ability → Server sends confirmation remote event to the client → Client receives and calls animation module(module script that contains function objects that play animations for respective abilities) to execute animation and sends another remote event to server called “UseAbility” → Server receives the “UseAbility” remote event and subtracts energy and does hitbox checking.
When the animation module gets called, it also sends several remote events and functions to the PlayerStats module, server sided, to check if booleans dashing and jumping or true or false and changes PlayerStats variables canDash and canJump with remote functions.
Also in animation module, when the animation finishes playing, the move ends and sends [movename]Ended binding event to client script to tell the client that they can receive moves again.
Is this method efficient? When I test the game out, there is notable delay between when I press mouse button 1 and the animation actually firing.
In what ways can I improve the speed and efficiency?
i dont think this is necessary is it possible to try and use the animation module on the server?
This is also unnecessary, do the checking with booleans on the server side. You can accomplish this by creating an empty table and assign a key value pair of the player and their boolean state
heres what I mean
local canJump = {}
-- setting the canjump to false for the player
canJump[player] = false
if canJump[player] then
...
end
I dont think this is necessary as well have the server script change whether or not the player can move again or not.
It would really help if you can post some of your code.
Client (User presses button) → [Remote Event] → Server Checks if stats are enough, if yes, subtracts energy, changes state boolean, sends → [Remote Event to every client so every player can see the animation of the ability] → Every client plays animation, when animation ends only the client of the user who used the ability will → [Remote Event to Server] → Server changes the isUsingMove1 state boolean back to false.
So only 3 remote events and some bindable events but bindable events don’t cause ping since they are server to server or client to client script.
I need to change state booleans to prevent moves from canceling out other moves, like if the user spams Move 1 or uses Move 1 and then suddenly presses move 2, the state booleans let the server reject the requests.