So first of all you need to turn on studio api services. So instead of using that script, I would recommend using this. So insert a script in ServerScriptService and name it whatever you want, copy and paste this code in it. Every time you add a new stat then, basically make another line under savevalue = plr.leaderstats.Points and type in something like savevalue2 = plr.leaderstats.Cash and dont forget to do savevalue2.Value and at very bottom put a comma after the leaderstats.Points.Value and add plr.leaderstats.Cash.Value. Hope this was helpful.
local DS = game:GetService("DataStoreService"):GetDataStore("Datae")
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrkey = "id_"..plr.userId
local savevalue = plr.leaderstats.Points
local GetSaved = DS:GetAsync(plrkey)
if GetSaved then
savevalue.Value = GetSaved[1]
else
local NumbersForSaving = {savevalue.Value}
DS:GetAsync(plrkey, NumbersForSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
DS:SetAsync("id_"..plr.userId, {plr.leaderstats.Points.Value})
end)
4 comments
Is that the entire script or have you cut out most of it?
That is all
Well are you trying to get the stats back after saving or do you want to save more than just the points? That saves and works easily
i want to get the stats back after saving