Issue with ping script/ui

Im working on a script to display your ping and show an internet icon with it to make it feel more appealing, the issue is sometimes it doesnt update


The code doing the ping ui:

local PingThread = coroutine.wrap(function()
	while wait() do
		local Ping = tonumber(string.format("%.3f", GetPing() * 1000))
		PingCounter.Text = (math.floor(Ping)).." ms"

		if Ping <= 40 then
			PingImage.ImageColor3 = Colors.Good
			PingImage.Image = InternetIcons.Perfect
		elseif Ping <= 80  then
			PingImage.ImageColor3 = Colors.Good
			PingImage.Image = InternetIcons.Good
		elseif Ping <= 120  then
			PingImage.ImageColor3 = Colors.Normal
			PingImage.Image = InternetIcons.Medium
		elseif Ping <= 160  then
			PingImage.ImageColor3 = Colors.Normal
			PingImage.Image = InternetIcons.Bad
		elseif Ping <= 205  then
			PingImage.ImageColor3 = Colors.Normal
			PingImage.Image = InternetIcons.Horrible
		elseif Ping <= 250  then
			PingImage.ImageColor3 = Colors.Normal
			PingImage.Image = InternetIcons.SuperBad
		elseif Ping > 800  then
			PingImage.ImageColor3 = Colors.Bad
			PingImage.Image = InternetIcons.NoInternet
			
		end
	end
end)

PingThread()

The code handling the ping (CLIENT):

function GetPing()
	local Send = tick()
	local Ping = nil

	PingRemote:FireServer()

	local Receive; Receive = PingRemote.OnClientEvent:Connect(function()
		Ping = tick() - Send 
	end)

	wait(1)

	Receive:Disconnect()

	return Ping or 999
end

The code handling the ping (SERVER):

local PingRemote = script.Parent.Handler.GetPing
PingRemote.OnServerEvent:Connect(function(Client)
	PingRemote:FireClient(Client)
end)

Here is how it looks:
image
(Emeginlebul is the icon changing thingy

local FPSCounter = script.Parent.Holder.FPS
local PingCounter = script.Parent.Holder.Ping
local PingImage = script.Parent["emeginlebul!"]

local Colors = {
	Good = Color3.fromRGB(174, 255, 161),
	Normal = Color3.fromRGB(255, 169, 93),
	Bad = Color3.fromRGB(255, 97, 97)
}```
Help would be appreciated, thanks!
3 Likes