Task.wait(1) waits less than 1 second?

I see, do you think I should still use os.clock in production as well? Since it seems to work better than time() in lag spikes (or just the server starting).

It depends on what you’re using os.clock for. I’m not sure of what purpose it has in production.

Im using it like this:

lastTimeRan = os.time()
task.wait(4)
If os.time() - lastTimeRan >= 4 then continue with the script

it’s purpose is to be a kind of time debounce for stamina regen
(if player does action that takes stamina, make lastTimeRan current os.time(), wait 4 seconds then check if os.time() - lastTimeRan is bigger than 4, if it is do the regen)

if the player does another action let’s say 2 seconds later lastTimeRan will be the current os.time() and so the first time the script happens, it wont continue.

It can work for that, but I think that you should use other variables instead. One other issue is that CPU time will obviously be different between each client and the server. So if you’re looking to sync either, os.clock would not be the way to go for that.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.