Is there are anyway that I can get accurate ping for player?

Hello Developers.

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??

8 Likes

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:

  1. 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.
  2. 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.

5 Likes

So do I just do :GetNetworkPing() then multiply it by 2000?

2 Likes

It is essentially that is what have to do.

1 Like

I tried to do that but the ping is 0…

1 Like

I told you again, this behavior is intended in Studio: It is always 0 because the testing is on a local machine.

3 Likes

Hello there.

So I just tested it and it is still not accurate. Do you any others solution??

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:

  1. Workspace:GetServerTimeNow()
  2. os.time()
  3. 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.

Oh well!

There was actually other topics you could try to scourge up to find solutions:

Use an unreliable remote event for the alternative solution.

1 Like
1 Like

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.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.