Why does GetNetworkPing return 0

Maybe I’m using :GetNetworkPing wrong, but just to test and see the kind of values it spits out (since the Documentation doesn’t give anything about using it), I wrote some simple code looping through and grabbing ping.

-- The following code is written in a Server Script, sitting in ServerScriptService.
local players = game:GetService("Players")
local serverRun = true

while serverRun == true do
	local plrs = players:GetPlayers()
	for _, plr in pairs(plrs) do
		local ping = plr:GetNetworkPing()
		print(ping)
	end
	wait(5)
end	

The results are simply “0” every time it prints, whereas you can see my ping according to the Performance Stats shows quite the opposite.

Any ideas of why it would be reporting back 0?

Edit: I tested in-game (play button on the play page) rather than in-studio. If I re-call, playing in studio runs the “server” locally, so then it would of course output 0?

1 Like

I think GetNetworkPing is not complete, explaining why the documentation is empty and why it returns 0.

2 Likes

This is still an issue, anyone know what’s up?

2 Likes

Is this a local script orna serger script?

I think you’re late a bit heh.

According to the wiki you can only run it on the client:

Source

If im not wrong, GetNetworkPing should return a float value in seconds (30ms = 0.03s), studio is local hosted and returns 0.

You can try to multiply it by 1000 or converting it to string before printing, let us know if this works.

Another post about this:
[Solved] Server side GetNetworkPing

This post is over a year old.

GetNetworkPing no longer is horrifically broken like it used to be. GetNetworkPing accurately displays a decimal number now, rather than simply reporting back “0”.

Incorrect. You can run it on the server by calling for a player, with the attached function.
However, if the function is run in a local script then you can only call the local player.

If this was the case back then, multiplying 0 by 1000 would not change the fact it was 0. Printing
a float doesn’t round it to the nearest int.

I specifically stated that I didn’t test in studio to avoid this exact reason.

This post is resolved, the problem that I faced one year ago no longer exists.

2 Likes