How do i fix this lag/ping gui?

Hello guys, have a good day. Today i wanted to add a ping gui to my game. Maked by Shedletsky, but its not updated so you guys can help me to fix this?

It needs to be like this.
image
But it’s like this
image

There’s lua
print ‘Admin Console 1.0 Loaded’

–[[

Hio. Make sure you have the latest and greatest version of this tool. Get it at http://ironnoob.com/forums/index.php/board,26.0.html

  • John Shedletsky

]]–

– Install Gui
local copy = script.JohnsConsoleGui:Clone()
–copy.Archivable = false
copy.Parent = game.StarterGui

local lastPing = {} – {player, ms}

function split(str, delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( str, delimiter, from )
while delim_from do
table.insert( result, string.sub( str, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( str, delimiter, from )
end
table.insert( result, string.sub( str, from ) )
return result
end

function getAvgPing()

local p = game.Players:GetPlayers()
local total = 0 

for i=1,#p do
	if lastPing[p[i].Name] ~= nil then
		total = total + lastPing[p[i].Name]
	end
end

if #p == 0 then return 0 end

return total / #p 

end

function incomingMessage(msg)
if string.sub(msg.Name, 1, 4) == “ping” then
print("SERV MSG: " … msg.Value)
local args = split(msg.Value, “,”)

	print("player: " .. args[1] .. "ping: " .. args[2])
	lastPing[args[1]] = args[2]

	local result = getAvgPing()
	print("avg ping: " .. result)
	msg.Value = "." .. result
end

end

script.ChildAdded:connect(incomingMessage)

image

If i can fix this, i will upload the fixed file to ROBLOX, thank you guys.

Please make sure you format your code properly. For future readers, here is the code:

print ‘Admin Console 1.0 Loaded’

–[[

Hio. Make sure you have the latest and greatest version of this tool. Get it at http://ironnoob.com/forums/index.php/board,26.0.html

John Shedletsky
]]–

– Install Gui
local copy = script.JohnsConsoleGui:Clone()
–copy.Archivable = false
copy.Parent = game.StarterGui

local lastPing = {} – {player, ms}

function split(str, delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( str, delimiter, from )
while delim_from do
table.insert( result, string.sub( str, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( str, delimiter, from )
end
table.insert( result, string.sub( str, from ) )
return result
end

function getAvgPing()

local p = game.Players:GetPlayers()
local total = 0 

for i=1,#p do
	if lastPing[p[i].Name] ~= nil then
		total = total + lastPing[p[i].Name]
	end
end

if #p == 0 then return 0 end

return total / #p 
end

function incomingMessage(msg)
if string.sub(msg.Name, 1, 4) == “ping” then
print("SERV MSG: " … msg.Value)
local args = split(msg.Value, “,”)

	print("player: " .. args[1] .. "ping: " .. args[2])
	lastPing[args[1]] = args[2]

	local result = getAvgPing()
	print("avg ping: " .. result)
	msg.Value = "." .. result
end
end

script.ChildAdded:connect(incomingMessage)

This appears to be the code for only the server side (server script, JohnConsole.) What does the code for the client (local script, ConsoleManager) look like?