How could I fix my friends leaderboard and stop datastore request queues from happening?

Hello, for my game I wanted to have a friends leaderboard that displays the high scores of your friends. My friend leaderboard works, but it causes data request queue warnings. Currently, the code gets the players friends using Players:GetFriendsAsync(player.UserId. Basically the only problem and the reason this is happening is because im checking players who have not played, and if they havent I go to the next iteration but if they did and data exists then i send the data to the client.

Games like Watermelon GO and Egg Farm Simulator have friend leaderboards, and they work but progressively load. How could I make a leaderboard like that, and what can I do to fix my current system but also ensure loading all friends that have played the game and checking for friends that could possibly play the game?

I’ve tried many things, as you can see in the code below, like checking badge ids untill I can no longer request them, but I still get data requests even with profileservice.

PS: When im playing solo i dont get any data request queue warnings, but when I’m playing with 2 or more people I get the data requests queue warning. Help would be much appreciated, as I’ve been trying to optimize my friends leaderboard for a while now.

local successD, page = pcall(function() return Players:GetFriendsAsync(player.UserId) end)
			if successD then
				task.spawn(function()
					while task.wait() do
						for i, v in pairs(page:GetCurrentPage()) do
							local userId = v.Id

							if Cache[player.UserId][tostring(userId)] ~= nil then
								continue
							end

							local s, hasBadge = pcall(function()
								return badgeService:UserHasBadgeAsync(userId, welcomeBadge)
							end)

							if s and hasBadge == false then continue end
							-- Profile Service, uses viewprofileasync();
							local friendData = playerDataHandler:GetOfflineProfile("Player_"..userId)
							if friendData == nil then continue end
							
							local success, countryValue = pcall(function()
								return countryData:GetAsync(userId)
							end)
							
							-- the country data retrives the players country, thats all
							
							local country = ""
							if success and countryValue ~= nil then
								country = countryValue.Emoji
							end
							local username = v.Username

							local image = "https://www.roblox.com/headshot-thumbnail/image?userId="..userId.."&width=48&height=48&format=png"

                            on += 1
							dataTab[on] = {
								["UserName"] = username.." "..country,
								["ProfileIcon"] = image,
								["Score"] = friendData["High Score 🏆"] or 0
							}
							task.wait(0.1) 
						end
						table.sort(dataTab,function(a,b)
							return a.Score > b.Score
						end)
					
                     game.ReplicatedStorage.Remotes.Client:FireClient(player,"updateLB",dataTab,"Friends")
						if page.IsFinished then
							break
						end
						page:AdvanceToNextPageAsync()
					end
				end)
			end

Anyone able to help? been trying to solve this for a while now

Hey, would like to know if you found a solution to this, I’m also trying to make a friends leaderboard system. Thanks.