Tables are not saving

As long as you handle loading and save locking (which even that isn’t needed), SetAsync is better. People worry about it because it overwrites, but it’s never really an issue (especially now with data versioning). UpdateAsync really only works with saving int values and it counts against both read and write limits, where as SetAsync is for all data, including tables storing things other than just int values, and only counts against the write limit. Plus the all-or-nothing approach is probably safer anyway. But that’s just from my experience. If that works better for you, keep at it. :+1:

hi, thanks for sharing this video, but how can i save Tables?

hi, i changed my code a little yet it still doesnt work, it gives no errors nor warnings.

--Server script
local remotecon = require(game.ServerScriptService.remotescript)


local buytool = game.ReplicatedStorage.Remotes.buytool -- wherever the remote event is

local toolactivated = game.ReplicatedStorage.Remotes.activatetool
local sell = require(game.ServerScriptService.sell)

buytool.OnServerInvoke = function(player, toolName, status)
	local something = remotecon.buy(player,toolName, status)
	return something
end

game.ReplicatedStorage.Remotes.strength.OnServerInvoke = function(plr , toolName)
	plr.leaderstats.Strength.Changed:Connect(function(value)
		math.clamp(plr.leaderstats.Strngth.Value , 0 , plr.Storage.Value)
	end)
end

local buyst = game.ReplicatedStorage.Remotes.buyst -- wherever the remote event is

buyst.OnServerInvoke = function(player, storagen, status)
	local something = remotecon.buyst(player,storagen, status)
	return something
end

local buycl = game.ReplicatedStorage.Remotes.buycl -- wherever the remote event is

buycl.OnServerInvoke = function(player, classname, status)
	local something = remotecon.buycl(player,classname, status)
	return something
end

toolactivated.OnServerEvent:Connect(function(player)
	remotecon.toolactive(player)
end) 

local httpService = game:GetService('HttpService')
local dss = game:GetService("DataStoreService")
local ds = dss:GetDataStore("datamaSnef")
local players = game:GetService("Players")

local loadedPlayers = {}

players.PlayerAdded:Connect(function(player)
	local data = ds:GetAsync(player.UserId)
	
	if data  then
		data = httpService:JSONDecode(data)
		local tooldata = nil
		for key,value in pairs(data) do
			pcall(function()
				player.leaderstats[key].Value = value
				tooldata = ds:GetAsync(player.UserId.."ownedtools")
				tooldata = httpService:JSONDecode(tooldata)

			end)
		end
		for _,toolname in pairs(tooldata) do
			local val = Instance.new("StringValue")
			val.Name = toolname
			val.Parent = player.Ownedtools
		end
		
	end
	table.insert(loadedPlayers,player)
end)

players.PlayerRemoving:Connect(function(player)
	
	
	local found = table.find(loadedPlayers,player)
	if found then
		table.remove(loadedPlayers,found)
		local saveData = {}
		local ownedtools = {}
		for _,value in pairs(player.leaderstats:GetChildren()) do
			saveData[value.Name] = value.Value
		end
		for i,v in pairs(player.Ownedtools:GetChildren()) do
			local val = Instance.new("StringValue")
			val.Name = v.Name
			val.Parent = player.Ownedtools
			table.insert(ownedtools,val)
			
			print("saved")
		
		end
		local function attemptSave(i)
			i = i or 0
			i+=1
			if not pcall(function()
					ds:SetAsync(player.UserId,httpService:JSONEncode(saveData))
					ds:SetAsync(player.UserId.."ownedtools",httpService:JSONEncode(ownedtools))
				end) then
				if i <= 10 then
					task.wait(1)
					attemptSave()
				end
			end
		end
		attemptSave()
	end
end)

please help ASAP , Thank you