I made a system for checking how long it takes for the game server to receive a client request with a remote function, then the server sends tick() back to be compared with tick() taken on the client before and after the request, but for whatever reason the server is responding with a number over 14000 more than both the before and after checks.
local servertick = tick()
print("server tick() " .. servertick)
PingCatcher.OnServerInvoke = PingCheck
It’s annoying because tick() should be the same no matter what region you are connecting from. It works just fine with ‘play solo’, but in a local test server the issue does happen although less off than the 14000 or so that it is on a live game server.
That’s not a correct assumption, tick() is influenced by configuration of the device. It’s generally not possible to assume (in most computing environments, not just Roblox) that two network entities under different authorities will have matching timestamps (also because clock syncing is inherently impossible for distributed systems).
The same is true for any other time method Roblox has that you might use on both the server and the client (os.time, etc). The user has authority over their own client so the timestamp may differ from the server’s for several reasons. (they have a bad timezone configured on their device, system time is inaccurate and hasn’t been synced recently, user maliciously/inadvertently modified their system time for any other reason to make the time values incorrect)
You can compare server timestamps with each other, and you compare client timestamps with each other, to get meaningful differences you can reason about. Comparing a server timestamp with a client timestamp however is not meaningful as anything but for calculating an offset since their time sources are different. This is not something Roblox can fix.
I didn’t realize tick() was dependent on device configuration when web-connected ingame. The whole reason why I was wanting to this was to see ‘send ping’ and ‘receive ping’ to better figure out server response ingame like I’ve seen in other games. It would be nice if there were some easily referenced ways to do things like check server response time and ping.
A simple way to estimate ping to the server is to have the clients send a request to the server, where the server just responds immediately with nothing. The client can keep track of the time it sent and received the event, then half that to get somewhat of an estimate of the network delay to the server.
It should be noted that due to the fact you don’t have control over when network events fire (e.g. they are queued up and fired at the end of every frame, or X times per second otherwise), you are incapable of calculating a very accurate ping through this method since there is additional processing delay before your message is actually sent over the wire and when it is received again and processed by Lua.
I am already doing that, to get the ‘close enough’ round-trip ping, but I wanted to also get ‘close enough’ one-way times since there was already a return, to better get an idea of how long the server is actually taking to process the request.
In any case, thank you for responding to my dumb question/issue.