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)
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)
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:
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.