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


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
