local level = game:GetService("DataStoreService"):GetDataStore("Level")
local xp = game:GetService("DataStoreService"):GetDataStore("EXP")
local totalxp= game:GetService("DataStoreService"):GetDataStore("totalxp")
local gold = game:GetService("DataStoreService"):GetDataStore("gold")
local win= game:GetService("DataStoreService"):GetDataStore("Wins")
local death= game:GetService("DataStoreService"):GetDataStore("Deaths")
function save(dataname, playerid, value)
game:GetService("DataStoreService"):GetDataStore(dataname):SetAsync(playerid, value)
end
I've been saving multiple stats like gold, wins, exp like this, and I used to make it so whenever exp changed it would save all the values, and sometimes it was too much for the server to handle.
save("Level",player.UserId,player.leaderstats.Level.Value)
save("EXP",player.UserId,player.EXP.Value)
save("totalxp",player.UserId,player.xpremaining.Value)
save("gold",player.UserId,player.Coins.Value)
save("Wins",player.UserId,player.Wins.Value)
save("Deaths",player.UserId,player.Deaths.Value)
Is there a way to prevent saving issues in the future if it can't all be handled to save all this when the xp is changed or when the player leaves?

1 comment
Try saving the values in one datastore as {Exp = Experience.Value, Lvl = Level.Value, Gold = Gold.Value} etc.you can then read these values out of your table by doing TableName.Exp or TableName.Gold. Also, save once in a while & on disconnect. not every time a value changes.