Code:

local DS = game:GetService("DataStoreService"):GetDataStore("Data")
game.Players.PlayerAdded:Connect(function(plr)
	wait()
	local plrkey = "id_"..plr.userId
	local savevalue = plr.leaderstats.Money
	local savevalue2 = plr.PlayerStats.Sitem
	local savevalue3 = plr.leaderstats.Rebirths
    local GetSaved = DS:GetAsync(plrkey)
	if GetSaved then
	savevalue.Value = GetSaved[1]
	savevalue2.Value = GetSaved[2]
	savevalue3.Value = GetSaved[3]
	else
	local NumbersForSaving = {savevalue.Value, savevalue2.Value, savevalue3.Value}
	DS:GetAsync(plrkey, NumbersForSaving)
	end
    end)
game.Players.PlayerRemoving:Connect(function(plr)
	DS:SetAsync("id_"..plr.userId, {plr.leaderstats.Money.Value, plr.PlayerStats.Sitem.Value, plr.leaderstats.Rebirths.Value})
end)

7 comments

0

Use code block.

0

Ok

0

You should probably use pcall on set async

0

where?

0

Is this your full code?

0

Besides, on line 8, it should be local GetSaved = DS:GetAsync("Money",plrkey) and you should repeat this for the Sitem and rebirth

0

This is my full code