I have 3 sets of these and in the ouput it said
“DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key”
I want this scripts combined unless there is a better way
local DataStore = game:GetService("DataStoreService")
local WinsLB = DataStore:GetOrderedDataStore("DonationLeaderboards")
local leaderboard = game.Workspace.Leaderboard
local function updateLeaderboards()
local success, errorMessage = pcall(function()
local Data = WinsLB:GetSortedAsync(false, 10)
local Winspage = Data:GetCurrentPage()
for rank, data in ipairs(Winspage) do
local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
local userId = game.Players:GetUserIdFromNameAsync(userName)
local Wins = data.value
local isOnLeaderboard = false
for i, v in pairs(leaderboard.SurfaceGui.Holder:GetChildren()) do
if v:IsA("Frame") then
if v.Player.Text == userName then
break
end
end
end
if Wins and isOnLeaderboard == false then
local NewLBFrame = game.ReplicatedStorage.LeaderboardFrame:Clone()
local statLabel = NewLBFrame.Stat
NewLBFrame.Player.Text = userName
statLabel.Text = Wins
NewLBFrame.Rank.Text = "#"..rank
--NewLBFrame.Position = UDim2.new(0, 0, NewLBFrame.Position.Y.Scale + (0.1 * #donationBoard.SurfaceGui.Holder:GetChildren()), 0)
NewLBFrame.Parent = leaderboard.SurfaceGui.Holder
if rank == 1 then -- this is how rank one willl look like
NewLBFrame.Player.TextColor3 = Color3.new(1, 0.705882, 0.227451)
statLabel.TextColor3 = Color3.new(1, 0.705882, 0.227451)
NewLBFrame.Rank.TextColor3 = Color3.new(1, 0.705882, 0.227451)
--NewLBFrame.Avatar.BackgroundColor3 = Color3.new(0.997803, 0.884443, 0.247959)
elseif rank == 2 then
NewLBFrame.Player.TextColor3 = Color3.new(0.721294, 0.721279, 0.721279)
statLabel.TextColor3 = Color3.new(0.721294, 0.721279, 0.721279)
NewLBFrame.Rank.TextColor3 = Color3.new(0.721294, 0.721279, 0.721279)
--NewLBFrame.Avatar.BackgroundColor3 = Color3.new(0.721294, 0.721279, 0.721279)
elseif rank == 3 then
NewLBFrame.Player.TextColor3 = Color3.new(0.736507, 0.487678, 0.259174)
statLabel.TextColor3 = Color3.new(0.736507, 0.487678, 0.259174)
NewLBFrame.Rank.TextColor3 = Color3.new(0.736507, 0.487678, 0.259174)
--NewLBFrame.Avatar.BackgroundColor3 = Color3.new(0.736507, 0.487678, 0.259174)
end
end
end
end)
if not success then
print(errorMessage)
end
end
while true do
for _, player in pairs(game.Players:GetPlayers()) do
local stat = player.leaderstats.Parts -- type your currency's name here!
WinsLB:SetAsync(player.UserId, stat.Value)
end
for _, frame in pairs(leaderboard.SurfaceGui.Holder:GetChildren()) do
if frame:IsA("Frame") then
frame:Destroy() -- this deletes the frame to restart it.
end
end
updateLeaderboards()
wait(10) -- this is the update time
end
local dataStoreService = game:GetService("DataStoreService")
local dataStore = dataStoreService:GetDataStore("myDataSotre")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = player:WaitForChild("leaderstats")
local parts = Instance.new("IntValue")
parts.Name = "Parts" -- currency's name
parts.Value = 0 -- cash value
parts.Parent = leaderstats
local data
local succes, errormessage = pcall(function()
data = dataStore:GetAsync(player.UserId.."-Parts") -- Getting the key
end)
if succes then
parts.Value = data
else
print("Didin't get parts data.")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local succes, errormessage = pcall(function()
dataStore:SetAsync(plr.UserId.."-Parts", plr.leaderstats.Parts.Value) -- inserting the key
end)
if succes then
print("Saved Patrs data.")
else
print("Didin't save parts data.")
warn(errormessage)
end
end)