Hello, I was wondering how I could make a Ping reader GUI? I have already made an FPS reader GUI and I tried turning it into a Ping Reader but it didn’t work here is my FPS reader code.
local fps = 0
local rs = game:GetService("RunService")
rs.RenderStepped:Connect(function()
fps = fps + 1
end)
while true do
script.Parent.Text = "FPS: "..fps
fps = 0
wait(1)
end
And here was my Attempted Ping Reader GUI (But it still just read your FPS even though it looked like this)
local Ping = 0
local rs = game:GetService("RunService")
rs.RenderStepped:Connect(function()
Ping = Ping + 1
end)
while true do
script.Parent.Text = "Ping: "..Ping
Ping = 0
wait(1)
end
Ping, otherwise called Latency, is how many seconds it takes to send data to another device, such as the server. Getting the player’s ping would need you to use a RemoteFunction that invokes a request to the server and the server will get back to the client:
-- Server
RemoteFunction.OnServerInvoke = function(player)
return "received"
end)
-- Client
local t = tick()
RemoteFunction:InvokeServer()
local ping = ((tick() - t) / 2) * 1000 -- time it takes in milliseconds
You’d need to do this about once every second to reduce the traffic over the network
@MrMouse2405 Physics FPS is different from Render FPS; That function returns how frequently the physics is updated every second, not how frequently the world is rendered on their screen.
The correct way to get the FPS would be what @Legoracer said