generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Issue with tick() going backwards

Previous Thread :: Next Thread 
Scavagious is not online. Scavagious
Joined: 13 Jun 2013
Total Posts: 83
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 is not online. 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
HandOfBrand is not online. HandOfBrand
Joined: 03 Apr 2008
Total Posts: 1552
26 May 2014 11:00 AM
It's being called in a Server Script.
Report Abuse
Scavagious is not online. Scavagious
Joined: 13 Jun 2013
Total Posts: 83
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
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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
Scavagious is not online. Scavagious
Joined: 13 Jun 2013
Total Posts: 83
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
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image