Datastore not working

this datastore saves data through a folder but for some reason it errors “invalid arguement to pairs table expected got nil”
in line 10

local ds = game:GetService("DataStoreService"):GetDataStore("some")
local folder = game.ReplicatedStorage.EconomyStuff.Cloud
local folder3 = game.ReplicatedStorage.EconomyStuff.Leaf
local folder4 = game.ReplicatedStorage.EconomyStuff.Mist
local folder7 = game.ReplicatedStorage.EconomyStuff.Sand
local folder13 = game.ReplicatedStorage.EconomyStuff.Stone
local folder14 = game.ReplicatedStorage.EconomyStuff.Points
	local values = ds:GetAsync("some")
	for i,v in pairs(values) do
		for i,b in pairs(folder:GetChildren()) do
			if v.Name == b.Name then
				b.Value = v.Value
			end
		end
end
for i,v in pairs(values) do
	for i,b in pairs(folder3:GetChildren()) do
		if v.Name == b.Name then
			b.Value = v.Value
		end
	end
end
for i,v in pairs(values) do
	for i,b in pairs(folder4:GetChildren()) do
		if v.Name == b.Name then
			b.Value = v.Value
		end
	end
end
for i,v in pairs(values) do
	for i,b in pairs(folder7:GetChildren()) do
		if v.Name == b.Name then
			b.Value = v.Value
		end
	end
end
for i,v in pairs(values) do
	for i,b in pairs(folder13:GetChildren()) do
		if v.Name == b.Name then
			b.Value = v.Value
		end
	end
	end
for i,v in pairs(values) do
	for i,b in pairs(folder14:GetChildren()) do
		if v.Name == b.Name then
			b.Value = v.Value
		end
	end
end

game:BindToClose(function()
	local folder = game.ReplicatedStorage.EconomyStuff.Cloud
	local folder3 = game.ReplicatedStorage.EconomyStuff.Leaf
	local folder4 = game.ReplicatedStorage.EconomyStuff.Mist
	local folder7 = game.ReplicatedStorage.EconomyStuff.Sand
	local folder13 = game.ReplicatedStorage.EconomyStuff.Stone
	local folder14 = game.ReplicatedStorage.EconomyStuff.Points
	local toSave = {}
	local success,err = pcall(function()
		for i,v in pairs(folder:GetChildren()) do
			local valuetable = {}
			valuetable.Name = v.Name
			valuetable.Value = v.Value
			table.insert(toSave,valuetable)
		end
		for i,v in pairs(folder3:GetChildren()) do
			local valuetable = {}
			valuetable.Name = v.Name
			valuetable.Value = v.Value
			table.insert(toSave,valuetable)
		end
		for i,v in pairs(folder4:GetChildren()) do
			local valuetable = {}
			valuetable.Name = v.Name
			valuetable.Value = v.Value
			table.insert(toSave,valuetable)
		end
		for i,v in pairs(folder7:GetChildren()) do
			local valuetable = {}
			valuetable.Name = v.Name
			valuetable.Value = v.Value
			table.insert(toSave,valuetable)
		end
		for i,v in pairs(folder13:GetChildren()) do
			local valuetable = {}
			valuetable.Name = v.Name
			valuetable.Value = v.Value
			table.insert(toSave,valuetable)
		end
		for i,v in pairs(folder14:GetChildren()) do
			local valuetable = {}
			valuetable.Name = v.Name
			valuetable.Value = v.Value
				table.insert(toSave,valuetable)
		end
		ds:SetAsync("some",toSave)
	end)
	if success then
		print("saved!")
	else
		print("something went wrong while saving")
		warn(err)
	end
end)

Brother this is impossible to read, please format it in

code blocks

so we can read it!

local values = ds:GetAsync("some") could have not contained any data, in which case it would return nil, which would be an error when passed to pairs

You’re only assuming that it’ll return back a table but as a result it could return back nil if nothing has been found & you aren’t encasing it inside a pcall which would result in a lot more errors

how can i fix this to make it basically continue

local Data
local success, whoops = pcall(function()
    Data = ds:GetAsync("some")
end)

print(Data)

if success and Data then
   --Do all your loops and stuff here
else
    warn(whoops)
end