I’ve got a minute countdown in my game, right now it’s totally done on the server, but it makes me thing if the server is super laggy the player could end up with more time, correct? I know of delta time, but what worries me about using the client is that the player could manually give themselves more time. How could I prevent this?
You could store the current value of os.time() in a variable, then get the differential of that. That’s as accurate as it gets.
local timer = os.time()
wait(3)
print(math.floor(os.time() - timer))
Not exactly sure if this is what you need, but I’d thought I would post this anyways if it’s helpful.
If it done on the server there is no way it can be exploited, and for laggy players yes the timer will appear to have more seconds at the end because of the delay when firing the remote event to the client, but they will not be given more time. To help mitigate this issue you could update the client every few seconds/minutes, depending on the duration, with the correct time to help re-synchronize the time with the server. What you could also do is have a timer int value that the sever updates every second, and the client can just listen to changes in that int value, and this would prevent laggy players from having the incorrect time, and is a much easier solution.