Error 104: Cannot store Array in data store

The title explains it all. I can’t store an array inside my Data Store:
image

I published the game and have Studio Access to API Services enabled.

Here is the saving portion of my data store script. It is supposed to save the Name and Position of every part in workspace.Build (the player’s build.)

game.Players.PlayerRemoving:Connect(function(player)
	
	local build = workspace.Build
	
	local saveTable = {}
	
	local parts = build:GetChildren()

	for count = 1, #parts do

		local part = parts[count]
		
		table.insert(saveTable, {part.Name, part.Position})

	end
	
	dataStore1:SetAsync(player.UserId, saveTable)
	
	print ("Saved data for "..player.Name)

end)

Any help would be appreciated!

P.S. I checked the loading section and it works just fine.

You can’t store a Vector3 values inside a table. You need to turn part’s position to a table then put that table inside that array.

Do you mean storing Position.X, Position.Y, and Position.Z?

Vector3’s as well as other Roblox datatypes can’t be saved to the datastore, only three Lua datatypes can (string, table, number).

You would have to do something like this:

table.insert(saveTable, {part.Name, {part.Position.X, part.Position.Y, part.Position.Z})

Then on load,

part.Position = Vector3.new(table.unpack(table[2]))

(which is basically what BenMactavsin said)

Yes, exactly. You need to get XYZ values from Vector3 and turn it into a table.

Thank you for your help! It works great now!

P.S. I just wish the error message said Vector3 instead of Array. (I thought it was an issue with my table)

1 Like