Ping not measuring correctly

What I have now:

  • ‘PingRemote’ Remote Event in ReplicatedStorage
  • A Get Ping Local Script under GUI
  • A Ping Handler Script in ServerScriptService.

Here is the Local Script:

local PingRemote, pingVal = game:GetService("ReplicatedStorage"):WaitForChild("PingRemote"), script.Parent:WaitForChild("Ping")

while true do
	local send = tick()
	PingRemote:FireServer()
	repeat
		wait()
	until PingRemote.OnClientEvent
	ping = tick() - send
	ping = ping * 1000 -- I have manipulated this part few times but it's still not working fine
	pingVal.Value = ping
	wait(1.5)
end

And the Script:

local PingRemote = game:GetService("ReplicatedStorage"):WaitForChild("PingRemote")

PingRemote.OnServerEvent:Connect(function(player)
PingRemote:FireClient(player)
end)

I have tested everything in game on Roblox (not in Studio) and it’s not working (ping being 53 while avg. ping in console says 120).

I need help fast (please make changes to this Scripts and do not send links - I searched web for help but it was not working). Thanks.

Instead of a repeat - until loop, use PingRemote.OnClientEvent:Wait().

1 Like

Seems to be working right, thanks!