Client-Server having trouble syncing when loading events

Many PVP and fighting games use client-sided hitboxes for the combat to feel more responsive for the player. However, for PVP specifically, the server needs to check so that exploiters don’t take advantage of the client-side.

I have made a tool system that utilizes these client-sided hitboxes, however, the tool isn’t syncing the server and client scripts for activation correctly.
Sometimes when using the tool, the hitbox/tool ability won’t load in for the client but the server will still run the tool cooldown.

The activation works for the most part, just at random moments it won’t work and that can be really bad, especially for a PVP game. When it works, it works perfectly fine and there are no issues through there, I only have this one issue.


Video above is showing the issue happening, sometimes the ability won’t load with the client but the server will activate the cooldown upon use.

The system that I have set up uses:

  • Local script in the Player to send event signals.
  • RemoteEvent in ReplicatedStorage to link client to tool.
  • BindableEvent in the tool to load hitboxes in the client.
  • Server and a local script to activate the tool.
    (the client script loads in the hitbox, server does the damage after a hitbox is confirmed accurate)

Changing the locations of the events still bring up the same issue, the system I have right now is the latest change I have made to it.
I have tried altering the code to try and make the cooldown load after the client (i.e, connecting the hitbox before), but I am still held with the same issue.

The local script from the player sends signals for every input and allows for the player to hold down the main activate key (i.e, LMB from mouse, a button on mobile, and GamepadX for controller).

If there are any other things needed to fully solve this issue, let me know!

What is the code for the hitbox creation? Is there a condition for the hitbox creation? Is there a condition that the hitbox must exist before firing an event to the server?

I found a fix for this problem already; however, I do not know if it is the best optimized.

The player’s main input sender script now waits until the local script in the tool receives the signal from the Bindable Event. As the tool now sends a true boolean to signal that the tool is ready to run, then the input sender activates the remote event for the tool.

Hitbox creation is made with a module script in Replicated Storage (since hitboxes are ran in the client), then checked in a script in ServerScriptService if the hit is valid, and then a signal is fired with another Bindable Event in the server that the Tool receives to run damage.
However, I do not think that the hitbox is the problem, more that the bindable event and the remote event are somehow not syncing correctly (the Remote Event gets the signal somehow faster than the Bindable Event).

I recommend using a statehandler for something like this

2 Likes