FilteringEnabled Server -> Client Cooldown Question

I am creating a cooking game, and the players are able to cook using various stations. Once the server gets a ping from the server to update the other clients, the server checks if that player’s cooldown is finished. I wait for the cooldown on the server, then fireClient to tell the client he can use more stations.

(But my questions is if there is a better alternative to this, as this could possibly result in some latency? Idk how much tbh the cooldown is .2 of a second)

Also, I tried doing cooldowns on both the server and the client, but that makes the client out of sync with the other clients as the client passed, but the server denied the update request due to cooldown not being finished. (I could tell the client to reverse the change but the more the player uses the stations the more it has to catch up with due to cooldown mismatch)

What is the cooldown, I’m not sure I understand why you are having a cooldown on these requests?

Edit: Are you saying there’s a cooldown so people can’t spam switch between stations?

1 Like

Cooldown so the client cant just spam the remote, causing it to switch really fast.

Do you do it like

local lastRequest = os.time()
local event = game.ReplicatedStorage.EventName

function moveStation(plr)
      if os.time() - lastRequest > 0.2 then
             lastRequest = os.time()
      end
end

event.OnServerEvent:Connect(moveStation)

Nope, I just call a wait function once the action is complete…

Like a debounce?

yes

You could use a remote function? That returns a value every time, so you can wait for that instead. If you don’t know how they work, I recommend looking at this article on the wiki:

http://wiki.roblox.com/index.php?title=API:Class/RemoteFunction
http://wiki.roblox.com/index.php?title=Remote_Events_and_Functions#Using_RemoteFunctions

If it’s a request from the server to the client, why do you need a debounce on that? Surely the server’s not going to be spamming the client with requests?

well, the client sends a signal to the server for an action (then checks cooldown to make sure there is none), the server does an action then the cooldown, then fires a signal back to the client saying cooldown’s up.

So my question is, which is better, a cooldown on both client and server, or just the server.

keep in mind I update the items on the clients, not the server, and I don’t want clients getting out of sync

Please try to edit your post instead of spamming multiple posts. You can find the edit button where the “like” button would be on your own posts. :smiley:

image

1 Like