Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Grabbing The Servers Ping?

alright so there is probably some extremely simple line of code somewhere that i couldn't find but i am wanting to know if there is a way to grab the ping of the actual server like say perhaps take the value from the dev console and put it on a textgui or it that is not an option then get the average ping from each player and round it up into a value that i can slap on a textgui later which i know getting a localplayers ping is possible but im not sure how to do that either

1 answer

✓ Accepted answer

If you're trying to get a player's ping, you can simply just invoke a RemoteFunction and since the script will yield until it receives a reply, subtract the time it came back by the time you invoked the function. I'll provide a code example below...

Client:

local RemoteFunction = game.ReplicatedStorage.RemoteFunction

local function GetPing()
	local Start = tick()
	RemoteFunction:InvokeServer() -- Invoke a useless function to yield until given a reply.
	
	return tick() - Start
end

print(GetPing()) -- Oh, there's our ping! :)

Server:

local RemoteFunction = game.ReplicatedStorage.RemoteFunction

RemoteFunction.OnServerInvoke = function(plr)
	return true
end

Hope this helps! If you need any more information, feel free to ask.

If this helped, please remember to accept the answer.

1 comment

1

Thank you a lot man! this really didnt even cross my mind

This discussion is preserved as it was. New answers, comments, and votes are closed.