I AM NOT TOO FOND OF MARCH 18TH.
So I’m working on making a save system for the leaderboard stats in this fighting game that I’m working on without relying on this free model script I’ve been using for years, I found a really helpful video by JustSemplex that showed a really quick and simple way to save data so I used that code to put into the leaderboard script to save leaderboard stats.
Though I am having a small issue; I’m not sure if this is that big of an issue or not but once I leave the game, this message pops up into the console:
DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 1058091806
From the looks of it, it seems like from what this I guess warning is saying I’m somehow sending too many requests at once even though the script only saves once the player leaves the game?
Here’s the code for the Leaderboard itself:
game.Players.PlayerAdded:connect(function(plr)
local f = Instance.new("Folder", plr)
f.Name = "leaderstats"
local souls = Instance.new("IntValue", f)
souls.Name = "SOULs"
souls.Value = 0
local resets = Instance.new("IntValue", f)
resets.Name = "RESETs"
resets.Value = 0
local soulm = Instance.new("IntValue", f)
soulm.Name = "SOUL Mult"
soulm.Value = 1
end)
And here is the code for the save script inside the Leaderboard script:
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local Saver = DataStoreService:GetDataStore("SaveLeaderstats")
Players.PlayerAdded:Connect(function(player)
local Data = nil
local success, errormessage = pcall(function()
Data = Saver:GetAsync(tostring(player.UserId))
end)
if success then
if Data then
for i, v in pairs(Data) do
player:WaitForChild("leaderstats"):WaitForChild(i).Value = v
end
end
else
error(errormessage)
end
end)
local function Save(player)
local SavedData = {}
for _, v in pairs(player.leaderstats:GetChildren()) do
SavedData[v.Name] = v.Value
end
local success, errormessage = pcall(function()
Saver:SetAsync(tostring(player.UserId), SavedData)
end)
if not success then
error(errormessage)
end
end
Players.PlayerRemoving:Connect(Save)
game:BindToClose(function()
for _, v in pairs(Players:GetPlayers()) do
Save(v)
end
end)
I have read somewhere that using a table to store data would help, but from the looks of the last line of code it seems like it’s already using a table of some kind unless I’m mistaken? Or unless they were talking about the data inside of the Leaderboard script itself rather than the save script.
Again I’m not sure if this is like a huge issue or what, I just saw that warning in the console after I left the game and that got me wondering. Although if that warning does end up being an issue and somebody does have a solution for it then that would be greatly appreciated, thank you ! ^ ^
I AM NOT TOO FOND OF MARCH 18TH.