Why does tick() return a decimal number but os.time() returns an integer?

Anyone have any idea as to why this is? I’m trying to measure the time it takes for a request from the server to be received by the client, meaning I have to use os.time() so that the times are synced, however this means the smallest delay I can measure is 1 second, where as I need the ability to be able to measure fractions of a second.

print(tick()) -->> 1580660153.8355
wait(1)
print(tick()) -->> 1580660154.8423
wait(1)
print(os.time()) -->> 1580660156
wait(1)
print(os.time()) -->> 1580660157
1 Like

tick() extends to milliseconds iirc (which is after the .). os.time() just gives you the timestamp in seconds.

If you’re trying to sync stuff, you should combine the data from both to get ultra reliability.

2 Likes

os.time() is a vanilla Lua function. Vanilla Lua relies purely on the C implementation it runs in, and it is standard for that implementation (type time_t) to return an integer value.

tick() on the other hand is a Roblox function, and they took the liberty of making it more exact.

4 Likes

I use ReplicatedStorage.tick.value = tick() on the server to sync across clients/server.