GetServerTimeNow returning 0

workspace:GetServerTimeNow() unpredictably returns 0 for the client, causing major issues for a custom scheduler implementation that relies on being synced with the server

As far as I can tell this only happens in studio and not in the roblox app (playing via roblox prints expected values across all tests i conducted), and most of the time after a task.wait(1) it printed a correct value.

bug.rbxl (62.3 KB)
video

System information:
CPU: AMD Ryzen 9 7900 12-Core processor
Memory: 32 GB DDR5
GPU: NVIDIA GeForce RTX 3080 Ti

Beta features:

  • New Studio Camera Controls
  • Scene Analysis

Expected behavior

I expect the function to return the current server time as it does during a real play session.

4 Likes

Hi @k_nnetj ,

Thank you for your report and for including a video and repro place. We have identified that for connections over localhost, a player join can be very quick, racing the data from the server to the client which contains the initialization of the server’s time used by GetServerTimeNow().

Could you please confirm that this “0” return happens only at the start of play, typically on the very first call to GetServerTimeNow(), and never occurs if you wait(1) before the first call?

We will investigate ways to improve this API such that it is initialized immediately for every client. Until we do, a workaround would be to tolerate some small amount of startup time on the Client.

Apologies for this inconvenience, and thank you for the patience while we improve this.
PlumJar

From all of the tests inside of the reproduction file, it seems that the value is only ever 0 right at the start of the play session. For my own game, I implemented a while loop to keep updating the time variable while it was 0, and I have not encountered the issue since.

1 Like