A way to get current latency of each player

As a developer, it is currently very hard to accurately get the time taken for a message to go from client to server without using a complex method, such as a master clock and a slave clock. A method like this repeated sends remote events from client and server to keep them in sync, however, this is quite inefficient.
An example of such can be seen here.
Developers may have to account for other factors as well, such as tick() being different on both client and sever (such as time zones). There is the potential this could be easily exploited by the client and if Roblox implemented it, it may be harder for exploiters to break (however, I am aware it is entirely possible that exploiters can just hold back their traffic to appear to have higher ping). So even if its not secure it will be extremely convenient to developers.

Use cases for this includes, but is not limited to:

  • Preventing exploits; by being able to get what a client was doing at the exact time they were doing it, and acting an extra layer of anti-exploit reliability (reducing false-positives) as the server will be removing less players inaccurately.
  • Hit detection; when a client notifies the server about a shot being fired and between the time it takes for the message to reach the server, other players may have already moved a reasonable distance for a hit detected on the client, to not be detected on the server. This is clearly, not ideal as many people have ping >50ms which is enough to start to cause problems. Essentially, by being able to use ping and storing player positions, the developer is able to get where the players would have been when the client told the server (like how Call Of Duty does it).

Adding this would be extremely convenient as developers will not have to hard code in a master clock and a slave clock on the server and all clients to be able to get the ping of each player which may not even be accurate. It would also remove the need of extra remote events which would reduce the amount of data being sent between clients and server reducing stress on the network and improving performance.

My proposed solution is to add a checkbox on the remote event object. This would only affect the server side. It would appear as such: .OnServerEvent:Connect(function(player, ping, ...) and would default to false to keep scripts compatible.

21 Likes

I want to bump this feature request because it has not had any official response and yet is an essential feature to many other developers and me on the platform.

Currently, as a developer on Roblox, getting the latency of a player is a difficult task to do right. It is bad practice to invoke the client using a RemoteFunction because an exploiter can not respond, causing the server to hang or error. Any exploiter can delay a response to the server to fake a higher ping, potentially giving them an advantage in-game.

I’m sure Roblox already stores player latency internally for their own lag compensation. Giving developers access to this metric by exposing a Lua API would be invaluable to people trying to implement mechanisms such as lag compensation and accurate hit detection into their own games. Abusing it would be significantly harder for an exploiter than just hooking a RemoteFunction and waiting an extra second before sending a response. Not only that but providing an interface to retrieve a players ping leaves far less room for error on the developers end.

However, I am not a fan of the OP’s proposed solution. Personally, I would be more in favour of an exposed property or method on the Player instance so that it can be accessed without being bound to an event.

Thank you.

12 Likes