function Ping.Update()if tick()-LastUpdate<REQUEST_INTERVAL then return end LastUpdate=tick()for U,C in pairs(game.Players:GetChildren())do Ping.UpdatePlayer(C)end end function Ping.Init()System.Remotes.ConnectEvent("\080\105\110\103",function(U,C)if type(C)~="\110\117\109\098\101\114"or not Pool[U]or Pool[U].Code==-1 or Pool[U].Code~=C then return end Pool[U].Value=tick()-Pool[U].Time Pool[U].Code=-1 end)game.Players.PlayerAdded:Connect(function(U)Pool[U]={Code=-1;Value=0;Time=tick()}end)game.Players.PlayerRemoving:Connect(function(U)Pool[U]=nil end)end function Ping.ClientInit()Pool[game.Players.LocalPlayer]={Value=0}System.Remotes.ConnectEvent("\080\105\110\103",function(U)Pool[game.Players.LocalPlayer]={Value=U.Value}System.Remotes.FireServer("\080\105\110\103",U.Code)end)end return Ping
-- @outline // RUNNERS

function Ping.Update()
	if tick() - LastUpdate < REQUEST_INTERVAL then
		return
	end

	LastUpdate = tick()
	for _, v in pairs(game.Players:GetChildren()) do
		Ping.UpdatePlayer(v)
	end
end

function Ping.Init()
	System.Remotes.ConnectEvent("Ping", function(plr, Code)
		if type(Code) ~= "number" or not Pool[plr] or Pool[plr].Code == -1 or Pool[plr].Code ~= Code then
			return
		end

		Pool[plr].Value = tick() - Pool[plr].Time
		Pool[plr].Code = -1
	end)

	game.Players.PlayerAdded:Connect(function(plr)
		Pool[plr] = {
			Code = -1,
			Value = 0,
			Time = tick(),
		}
	end)

	game.Players.PlayerRemoving:Connect(function(plr)
		Pool[plr] = nil
	end)
end

function Ping.ClientInit()
	Pool[game.Players.LocalPlayer] = { Value = 0 }
	System.Remotes.ConnectEvent("Ping", function(tbl)
		Pool[game.Players.LocalPlayer] = { Value = tbl.Value }

		System.Remotes.FireServer("Ping", tbl.Code)
	end)
end

return Ping
