What is the difference between time() and tick()

I saw tick and time especially with my friends use often for cooldowns and anticheats, but what is more useful, time or tick

  • I saw my friend use time, but I use tick more often; but what is that difference?
  • The documentations have no answers for time and tick difference
1 Like

time() is the number of seconds since the game started, and tick() is the number of seconds since January 1st 1970. You can refer to the Wiki for more info here. Hope this works for you!

but is it better to use tick or time I subtract a variable that has a tick with the current tick

Tick is deprecated and less accurate. Use time instead

1 Like

I don’t really know it which context you use time(). However, It’s definitely better use time(), or task.wait(), just consider the context.

1 Like

There is no other function that replaces it. So is it really deprecated? You may argue os.clock() supersedes it but tick() is unix epoch time whereas os.clock() is local server time.

tick() returns the amount of time since january 1st 1970.

time() returns the amount of time in seconds since january 1st 1970.

Do you need it to be percise? Use tick. If not then use time(). Can’t decide? Use tick.

tick() doesn’t appear as reliable as you think. It was superseded by os.time() and os.clock(). Don’t use time() for timing-sensitive features, as it seems to be more whole seconds.

I reckon there was a spreadsheet comparing every time measurements via various of methods, noting their properties as well as if it goes backwards sometimes.

tick is not deprecated. I just checked the official documentation and it’s not deprecated. It’s simply less accurate.

As for time() and tick(). Use tick() or os.clock(). os.clock() is basically like time() that is it returns the time since the game started but is better and newer.

os.time() also exists but is worse because it returns in whole numbers. Here is the result:
1729843795 1729861795.0319085 (os.time() on the left and tick() of the right.)

(Letting you know here as well, correct me if I am wrong though.)

So technically speaking tick() is better because it returns the time in decimals while os.time() doesn’t.

what I am coding is an anticheat system and I am looking for a time calculation that has decimals are is accurate.

these should explain