|
| 26 May 2014 10:53 AM |
When a Player is in a server, I save the place every few seconds, setting: game.Workspace.LastTick.Value = tick()
When a Player joins the same place (after previous server shutdown), the LastTick value has successfully loaded. I then use a temporary variable: currentTick = tick()
The problem is, that the LastTick value is sometimes HIGHER than currentTick.
Meaning, the game somehow went backwards in time.
Is tick() not accurate? Random fluctuations? |
|
|
| Report Abuse |
|
|
powertool
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 3771 |
|
|
| 26 May 2014 10:57 AM |
Are you calling it from a serverscript or from a localscript? Differences are that if you call it from a serverscript, you get the server's current time since Unix epoch, and from a localscript you get that client's time since Unix epoch, relative to that client's time zone. If I call tick() in MST I'll get two hours difference compared to me calling it in EST at the same instant. |
|
|
| Report Abuse |
|
|
|
| 26 May 2014 11:00 AM |
| It's being called in a Server Script. |
|
|
| Report Abuse |
|
|
|
| 26 May 2014 11:02 AM |
Yes... it's a server Script.
The difference isn't something like two hours, as you mentioned, it's a seemingly-random number. It's sometimes a 40-second difference, sometimes a 50-minute difference. |
|
|
| Report Abuse |
|
|
|
| 26 May 2014 11:08 AM |
Use time() or os.time() (I can't remember which). If you use tick(), differences between time zones will be accounted for. Using os.time() will allow for synchronized times between all servers.
|
|
|
| Report Abuse |
|
|
|
| 26 May 2014 11:48 AM |
print(os.time())
This is great!
Do you know if there's any variation to os.time() resulting from different local time zones? |
|
|
| Report Abuse |
|
|
|
| 26 May 2014 11:51 AM |
On the server it should be synchronized between all time zones. Not sure about local calls. |
|
|
| Report Abuse |
|
|
lupine
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 3561 |
|
|
| 26 May 2014 11:53 AM |
| I was under the impression that calling os.time locally would return the local time of whomever called it. In my case, it'd be 9:52 am, as I'm in the PST zone. |
|
|
| Report Abuse |
|
|