I’m currently working on a project and I want to display the player ping accurately. I already read countless post that they told me to use :GetNetworkPing() method on the local player but it is very inaccurate and not recommend and the remote function method is not quite accurate too. So I just wondering what can you do to get the accurate ping of player or is it impossible??
When you talk about ping, I think people keeps mixing up the performance words and don’t actually know which is which sometimes, so let’s figure out what each part is first:
Ping is the delay in networking often impacts peer-to-peer communications(in this instance, client to server and vice versa). It is often measured in milliseconds. Additionally, Studio testing is not reliable for ping testing because it often is on 0 ms, unless you have added artificial lag.
The other part to performance is the frame rate. Frame rate is independent of the ping, unless the networking has to yield the renderer for a heavy task, freezing the frame briefly.
Reminder that this ping functionality is only one-way according to:
You’ll have to multiply it by 2 in order to get the estimate ping on the back and forth communication.
This is the code I was using to display the ping on the textlabel. Keep in mind that this is just a test code.
repeat task.wait() until game:IsLoaded()
while task.wait() do
script.Parent.Main.Ping.Text = math.floor(game.Players.LocalPlayer:GetNetworkPing() * 2000)
end
I would try a few different methods for getting time and I would send the time on the client when the ping is being measured to the server with a remote event. I would then use an equivalent time measurement on the server and see the difference. Ping is usually the time from when you send a request to get a response so you would probably need to multiply this figure by two. A few methods I would experiment with in no particular order:
Workspace:GetServerTimeNow()
os.time()
DateTime.now()
I would read the documentation carefully for these functions to make sure it will provide a number that is relevant to what you need. I also would recommend you make sure the timing functions are synchronized on the server and client. The functions I provided may or may not be what you need and they are just places to start.
I already looks through it. Thanks for your help. So the solution I have left is just to use :GetNetworkPing() * 2000 on client side because there are no others way of doing it.