workspace.DistributedTime begins when the server starts running/client enters the game, maybe you’re looking for that?
What I used to do is check if they have a reward, if so they fire a remote event, then the server rechecks. In case of an exploiter.
I mean, I think DistributedGameTime restarts once is a new server.
tick() is dependent on the time zone that the computer is set to.
My bad, I read a document wrong. tick() is indeed based on local time.
I would like Roblox to add a value that just keeps increasing but that is not time…
Can you please explain in detail what are you trying to achieve?
I know I can do this via a remote function, but still. I would like to have a number that keeps increasing, something like tick(), but that it doesn’t work depending on the time zone.
os.time() does exactly that. It returns the UTC time by default.
tick
is not deprecated afaik, though it is superseded by time
.
os.time()
is faster and more accurate, so it’s better to use that I’m pretty sure.
So, that will be the same for client and server?
It’ll not be equal, since it’s based on the machine’s time (not timezone). It’ll return the UTC time, but that time will still not be synchronized to the server’s UTC time. Nothing is stopping the player to change their time to the past or future. You can only trust that the server’s time is correct.
You could do something like add the server’s time to a NumberValue, so it’s visible to all clients.
os.time()
is not more accurate than tick()
or time()
.
It is rounded to the nearest second while the others are not. That could indicate that it might indeed be faster but I don’t know.
There’s also os.clock()
which has about 1 microsecond of precision and is intended for benchmarking.
Yea, I thought I got some of them confused. They all have similar names so it is kinda hard to differentiate.
@posatta
It does not count from when the server starts. It starts counting from when the local game instance starts.
That’s what a server is. A local game instance.
If you test time()
in Roblox Studio by starting a local server and then joining later as a player you will see that time()
returns different values on the server and the client.
Do not use the ‘Play’ button because that will start the server and the client at the same time.
Use the ‘Start’ button to launch a server and then add a single player later.
DateTime is the one that independent from both time zone and client computer’s time. We should always consider DateTime first whenever we need to use time stuffs.
DateTime didn’t exist at the time I made my replies. Check the date next time!