How can I get a players ping?

Hello! I am trying to get a players ping for when they join and it will print it, I’ve been trying to use

math.floor((os.clock() - os.clock()) * 1000)

But it doesn’t seem to print the ping, on studio and even in-game it just prints -1ms and sometimes it’ll print 0. How would I go along to be able to fix this?
image

Any help will be very much appreciated! Thanks! :smile:

1 Like

See Player:GetNetworkPing.

1 Like

Whenever I do that, it just prints 0.

Are you in Studio? The ping between you and yourself is 0.

No, I was not in Studio. I was inside the game itself. Also, if I do like a wait(5) then it’ll do that.
image

Since the ping is measured by timing packets, Roblox needs a chance to send and receive a few things from the client before being able to provide you with a value. There is no way around this. However, you probably don’t need to wait as long as five seconds—just don’t call the function as soon as they’ve joined.

From your screenshot, your ping is 32ms.

So you would do

print(player:GetNetworkPing() * 1000)

Correct?

Yes

Bro is doing smth minus itself and is confused on why its wrong

2 Likes