Ima be honest, I DONT HAVE ANY IDEA WHY ITS NOT WORKING, I checked my spelling, could find anything wrong. If you have any idea what can be wrong, feel free to comment. also the script is in server script service and yes, I have API turned on
local DS = game:GetService("DataStoreService"):GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrkey = "id_"..plr.userId
local save1 = plr.leaderstats.Cash
local GetSaved = DS:GetAsync(plrkey)
if GetSaved then
save1.Value = GetSaved[1]
else
local NumberForSaving = {save1.Value}
DS:GetAsync(plrkey,NumberForSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
DS:SetAsync("id_"..plr.userId, {plr.leaderstats.Cash.Value})
end)

3 comments
Have you already created the leaderstats folder?
wot error say
What part doesn't work exactly?