Why should "tick()" be avoided even tho It provide Milliseconds precision?

I was messing around with the time functions (os.clock, os.time, etc) and realised tick() was the only one with milliseconds precision based off the UNIX time, os.time is also based off UNIX but doesn’t return millisecond precision, now I needed precision on an UNIX timestamp, so naturally I would need to use “tick()” but i’ve heard it should be avoided, is there any counter part then?

2 Likes


Stated in this image it can be inconsistent

From Using tick() for handling time systems - #8 by sleitnick

As long as you’re only using tick() to compare to values from other calls to tick() on the same machine, there’s no problem. It’s fine for implementing timers or measuring elapsed time. Just don’t use it as an absolute reference for time or compare values from tick() calls made on different machines.

use workspace:GetServerTimeNow() for sync offset towards os.clock()
That it
The most optimal setup imo
Sync offset every ~5 minutes