Tick() time diffrent on client and server

Studio:


time is synced on client and server

In-game:


client-side ^


server-side ^

code:

local PlayTime = math.ceil(tick() - Player:GetAttribute(“JoinTime”))
print(PlayTime)
to see how much seconds you play it’s the same ^ (for client and server)

the attribute setting happens on server:

Players.PlayerAdded:Connect(function(Player)
task.spawn(function()
Player:SetAttribute(“JoinTime”, tick())

please any help!

1 Like

From the documentation on Roblox Globals:

tick() isn’t officially deprecated, but has a variety of issues. It can be off by up to one second and returns inconsistent results across time zones and operating systems. Use os.time(), os.clock(), or time() instead. Also consider DateTime.UnixTimestamp and DateTime.UnixTimestampMillis.

2 Likes

os.time() helped me, i also tried time() it does same problem

Pretty sure time() returns precise elapsed time since the environment started, meaning server and different clients will all return different times.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.