I have no idea how to start, here is the code that I used.

local ds = game:GetService("DataStoreService"):GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(plr)
	wait()
	local plrkey = "id_"..plr.userId
	local save1 = plr.leaderstats.Strength
	local save2 = plr.leaderstats.Cash
	local save3 = plr.leaderstats.Rebirths
	
	local GetSaved = ds:GetAsync(plrkey)
	if GetSaved then
		save1.Value = GetSaved[1]
		save2.Value = GetSaved[2]
		save3.Value = GetSaved[3]
	else
		local NumberForSaving = {save1.Value, save2.Value, save3.Value}
		ds:GetAsync(plrkey, NumberForSaving)
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	ds:SetAsync("id_"..plr.userId, {plr.leaderstats.Strength.Value, plr.leaderstats.Cash.Value, plr.leaderstats.Rebirths.Value})

2 comments

0

I forgot to say I never tested this in roblox player, only studio.

0

test it in roblox player then