Issue with my cooldown anti-cheat

Ok so for my cooldown system what I basically do is:
Fire remote event.
Remote event server script has the cooldown and it waits it out.
While the client is waiting the cooldown it essentially waits for the server script to fire back to the client confirming that the cooldown is over.

The way I tell if something is on cooldown is by adding a boolvalue to the player with the name of the ability thats on cooldown so I can simply check for this to determine if the move is on cooldown. That boolvalue obviously gets removed before I fire a remote back to the client.

Now the issue: On death I clear my cooldowns but there is one issue that can rarely occur. If someone is lagging and a remote event fires it could be delayed which means they could fire the remote event BEFORE they die but due to lag the event could actually be picked up AFTER they respawn resulting in that cooldown not being cleared on death when its supposed to and it can get them false flagged by the anti-cheat. How can I fix this?

I clearly did not understand what you are trying to do, but I realised the issue is the delay between the remote events due to lag. Now this is rare case. Though, what you can do is, instead of firing an event when a player dies, you can check if the player died on server. Do this by:

            --you can fire the remote event to client here or just clear the cooldowns when player dies.

Managing this on server can be efficient and it will make sure the player is not falsely flagged by your anti cheat.

1 Like

I already do that for the client. I also clear the cooldowns when the player respawns.

  1. Instead of solely relying on the client to determine when the cooldown is over, use the server as the authoritative source for cooldown management. When the client requests to use an ability, send a remote event to the server.

  2. On the server, handle the remote event by checking if the ability is currently on cooldown for that player. If it is, you can either ignore the request or send a response back to the client indicating that the ability is still on cooldown.

  3. If the ability is not on cooldown, perform the necessary actions and start the cooldown period. Store the cooldown end time in a data structure on the server, such as a dictionary or a table, associating it with the player.

  4. Whenever a player dies, handle the death event on the server and clear all the active cooldowns for that player. This ensures that any pending cooldowns will be reset upon respawning.

  5. To account for potential lag, you can introduce a grace period after the player’s death before clearing the cooldowns. During this grace period, any delayed remote events triggered before the death will still be able to clear the cooldowns. You can implement this grace period by using a delayed function on the server that waits a short duration after the player’s death before clearing the cooldowns.

1 Like

This is essentially already what I do for my system the issue is that u cant detect cooldowns before a players death since they should be cleared. But when the remote is delayed they dont get cleared. Is there a maximum amount of time a remote event could possibly be delayed that I could use for a grace period?

I don’t think there is a way to detect remote delay.
But if you want, I can have a look at the script (Not in public)
And see if I can find a better way.
I am mostly on Discord if you want: Master3395#0183