Could Someone Please Explain The "TimeSyncManager" Module Made By Quenty?

I’ve updated it to TimeSyncService!

Call :Init() on the client and server!

Then, you can get a synced clock, which is guaranteed to be synced.

-- main script, does not yield, so this on the client and server
require("TimeSyncService"):Init()

-- other script 
local TimeSyncService = require("TimeSyncService")

local syncedClock = TimeSyncService:GetSyncedClock() -- Yielding potentially on client! 

print(syncedClock:GetTime())

Alternatively you can use promises to get a synced clock:

-- main script, does not yield
require("TimeSyncService"):Init()

-- other script 
local TimeSyncService = require("TimeSyncService")

-- yay no yielding 
TimeSyncService:PromiseSyncedClock():Then(function(syncedClock)
    print(syncedClock:GetTime())
end)

This will result in a timestamp that is synchronized with the server! Accuracy is ± 1/30

22 Likes