Working on a part store, ran into an error

The error was [16:58:30.967 - 104: Cannot store Array in data store. Data stores can only accept valid UTF-8 characters.]
> local Remote = game.ReplicatedStorage.Remotes

local Save = Remote.Save
local Load = Remote.Load
local DataStore = game:GetService("DataStoreService")
local Store = DataStore:GetDataStore("Store", 1)
local ItemTable = {}
Save.OnServerEvent:Connect(function(Player, Folder)
	for i,v in ipairs(Folder:GetDescendants()) do
		if v:IsA("Part") then
			print(v.Parent.Name)
			print(v.CFrame)
			table.insert(ItemTable, 1 ,{v.CFrame, v.Parent.Name})
			Store:SetAsync(Player.UserId.."Items", ItemTable[1])
		end
	end
end)

Load.OnServerEvent:Connect(function(Player, Folder)
	for i,v in ipairs(ItemTable) do
		print(v)
	end
end) 

any advice?

I believe DataStores cannot store CFrame values, you need to serialize them into individual numbers.

Here’s a good tutorial on saving such values:

4 Likes

Fixed the problem thanks means a lot.

2 Likes

Pretty much, you have to save each value independently, i.e:

v.CFrame.x, v.CFrame.y, v.CFrame.z 
-- Example, you're breaking the CFrame down into 3 parts, and saving those 
--separately 

Correct. That’s basically what serialization is. But the CFrame class doesn’t have
.x, .y, .z properties. It has a .Position, an upVector, a rightVector and a lookVector.

1 Like