local DSService = game:GetService("DataStoreService"):GetDataStore("Cash")
game.Players.PlayerAdded:connect(function(plr)
	--Define Variables
	local uniquekey = 'id-'..plr.userId
	local leaderstats = Instance.new('IntValue',plr)
	local savevalue = Instance.new('IntValue')
	leaderstats.Name = "leaderstats"
	savevalue.Parent = leaderstats
	savevalue.Name = "Cash"
	
	--GetAsync
	local GetSaved = DSService:GetAsync(uniquekey)
	if GetSaved then
		savevalue.Value = GetSaved[1]
	else
		local NumbersForSaving = {savevalue.Value}
		DSService:SetAsync(uniquekey,NumbersForSaving)
		
	end
end)

-- When Player is Removed save data
game.Players.PlayerRemoving:connect(function(plr)
	local uniquekey = "id"..plr.userId
	local Savetable = {plr.leaderstats.Cash.Value}
	DSService:SetAsync(uniquekey,Savetable)
	
end)

I really dont understand why, i try it in game and it just doesnt work. Output gives no errors aswell.

1 comment

0

Moderating because your newer post is the updated version. Simply edit the question next time.