Is there some way to modify this code to prevent the Data Store limits from being reached if too many players join at once?
function CreateValue(Name, Parent, Value)
Value = Value or 0
local savevalue = Instance.new('IntValue', Parent)
savevalue.Name = Name
savevalue.Value = Value
return savevalue
end
function GetValue(uniquekey)
-- GetAsync
local GetSaved = DSService:GetAsync(uniquekey)
if GetSaved then
return GetSaved
end
end
game.Players.PlayerAdded:connect(function(plr)
local uniquekey = ID..plr.userId
local Levelss = Instance.new('IntValue', plr)
Levelss.Name = leaderboardname
for i,v in pairs(StatList) do
local Stat = GetValue(i..uniquekey)
if Stat then
CreateValue(i, Levelss, Stat) --Old player load their value
else
CreateValue(i, Levelss, v) --New player load the default value
end
end
end)
My DataStore script is pretty big, so when too many players join it fills up the requests and makes them wait a while for their data to load in. Is there any way to maybe make it so player's can manually load data? Or add some sort of wait to ensure that the limits aren't reached?
Thanks for reading

4 comments
Maybe don't save too often
Seriously, what is your problem dude?
It's a logical response, the issue is OP is saving way too often, so i'm giving a logical response: Don't save very often!
You can't even see how often the script is saving though. It saves every 5 min, so that isn't the issue :)