"104:Cannot store Instance in data store." even though I am trying to save normal array

Okay so for some reason I am unable to save this system of nested array to roblox datastore which I have the picture of it too by the way. Please do help if you know anything I might have missed
Screen Shot 2565-10-18 at 14.05.59


better screenshot because the other one was too small

Might have not capitilized a letter? Can I see script?


	local Base = game.Workspace.Bases.Plot1

	local SaveFile = {}


	local IsInPlot = function(Object,Center)
		local BaseSize = 100 +10
		local v3
		if Object:IsA("BasePart") then
			v3 = Center.CFrame:PointToObjectSpace(Object.Position)
		else
			v3 = Center.CFrame:PointToObjectSpace(Object.PrimaryPart.Position)
		end
		return (math.abs(v3.X) <= BaseSize / 2)
			and (math.abs(v3.Y) <= 5000)
			and (math.abs(v3.Z) <= BaseSize / 2)

	end



	--get PlayerStats
	local PlayerStats = {}
	PlayerStats[1] = 123456789
	--get PlayerStats finish





	--get Buildings
	local Buildings = {}
	for i,v in pairs(Base.Buildings:GetChildren()) do
		local BaseSize = 100 +20

		if v ~= nil and v:FindFirstChild("Configuration") and IsInPlot(v,Base.Center) then --put conditions

			local Config = v:FindFirstChild("Configuration")
			if true then


				local A = Instance.new("Attachment")
				A.Parent = Base.Center
				if v:IsA("BasePart") then
					A.WorldCFrame = v.CFrame
				else
					A.WorldCFrame = v.PrimaryPart.CFrame
				end

				local BuildingData = {[1] = Config.BuildingTag.Value,
					[2] = {[1]=A.Position.X,[2]=A.Position.Y,[3]=A.Position.Z},
					[3] = {[1]=A.Orientation.X,[2]=A.Orientation.Y,[3]=A.Orientation.Z},}

				A:Destroy()

				if v:FindFirstChild("BuildingValue1") ~= nil then
					BuildingData[4] = Config.BuildingValue1.Value
				end
				if v:FindFirstChild("BuildingValue2") ~= nil then
					BuildingData[5] = Config.BuildingValue2.Value
				end
				if v:FindFirstChild("BuildingValue3") ~= nil then
					BuildingData[6] = Config.BuildingValue3.Value
				end


				Buildings[#Buildings+1] = BuildingData

			end



		end
	end

	--get Buildings finish














	--get LooseBlocks
	local LooseBlocksData = {}
	for i,v in pairs(game.Workspace.LooseItems:GetChildren()) do
		local BaseSize = 100 +5

		if v ~= nil and v:FindFirstChild("Configuration") and IsInPlot(v,Base.Center) then --put conditions

			local Config = v:FindFirstChild("Configuration")
			
			if true then--Config.OwnerName.Value == Player.Name then


				local A = Instance.new("Attachment")
				A.Parent = Base.Center
				if v:IsA("BasePart") then
					A.WorldCFrame = v.CFrame
				else
					A.WorldCFrame = v.PrimaryPart.CFrame
				end

				local BlockData = {[1] = Config.BlockTag.Value,
					[2] = {[1]=A.Position.X,[2]=A.Position.Y,[3]=A.Position.Z},
					[3] = {[1]=A.Orientation.X,[2]=A.Orientation.Y,[3]=A.Orientation.Z},}

				A:Destroy()

				if Config:FindFirstChild("BlockValue1") ~= nil then
					BlockData[4] = Config.BlockValue1.Value
				end
				if Config:FindFirstChild("BlockValue2") ~= nil then
					BlockData[5] = Config.BlockValue2.Value
				end
				if Config:FindFirstChild("BlockValue3") ~= nil then
					BlockData[6] = Config.BlockValue3.Value
				end


				LooseBlocksData[#LooseBlocksData+1] = BlockData

			end



		end
	end

	--get LooseBlocks finish




	SaveFile[1] = PlayerStats
	SaveFile[2] = Buildings
	SaveFile[3] = LooseBlocksData




	print(SaveFile)

	local DSS = game:GetService("DataStoreService")
	local SaveFile = DSS:GetDataStore("TestFile2")
	return SaveFile:SetAsync(Player.UserId,SaveFile)

	--[[local Success, Error = pcall(function()
		return SaveFile:SetAsync(Player.UserId,LooseBlocksData)
	end)]]









end)

sorry if the script is a little messy

Thats all good. can you show me just the 1 line of code where it is erroring?

the error is linked to this line.

Maybe try this at that error line? I’m not too sure:

local success, err = pcall(function()
    return SaveFile:SetAsync(Player.UserId, LooseBlocksData)
else
    warn(err)
end)
1 Like

after I tried adding the pcall, it just work out of thin air. still have no ideas why it didnt work before but thanks for helping ig

1 Like

Thats interesting. I think I was meant to put:

local success, err = pcall(function()
    return SaveFile:SetAsync(Player.UserId, LooseBlocksData)
    
    if err then
       warn(err)
    end
end)