For accurate lap times, should I use os.time() or time()?

Hi! This is just a very simple question, I currently use time() for lap times in my racing game. I am worried time() may be affected by server lag. Should I use os.time() for more accurancy, or time()?

1 Like

For your racing game, use tick() instead of time() or os.time() because it provides precise, real-world timing (including milliseconds) and is not affected by server lag.

2 Likes

You should use time(). os.time() returns UTC time which can do strange stuff because of the need to keep it synced with the calendar and solar days. You must also make sure to only compare time() returned on the same machine. I.e. always use it on the server.

1 Like

what about tick()? i think server lag affects time() lol

1 Like

tick() is deprecated.
Since your game could lag, you want your times to also be affected by server lag. Otherwise, confusingly, your lap times will be affected by lag and players on less laggy servers will have better times.

2 Likes