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

game.Players.PlayerRemoving:Connect(function(plr)
	ds:GetAsync("id_"..plr.userId, {plr.leaderstats.Coins.Value, plr.leaderstats.Level.Value})
end) 

I was using tutorials and going off of what I know when I was making a script. I was making a data store for leaderstats. My leaderstats where working okay, but data wasn't saving. I got no errors either. Could some please help?

4 comments

0

could you put all the code into the code block

0

I dont know how to read it with the code everywher

0

I definitely recommend using this https://www.youtube.com/watch?v=n1UpT2csAzo

0

On line 7 i think you ment DS:SetAsync not GetAsync?