Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Cannot store Dictionary in data store?

So I made a placement system and you can change its color, material etc. But the only thing that doesnt work is saving the build. here is my script:

local partTable = {}
	
for i, inst in pairs(workspace:GetChildren()) do
	if inst.Name == "BuiltBlock" then
		local position = inst.Position
		local material = inst.Material
		local color = inst.BrickColor
		local size = inst.Size
		partTable[i] = {Position = position, Material = material, Color = color, Size = size}
	end
end
	
local success, err = pcall(function()
	BuildsDataStore:SetAsync(player.UserId, partTable)
end)
if err then
   print(err)
end

So when i try to save it, it prints: 104: Cannot store Dictionary in data store. Data stores can only accept valid UTF-8 characters.

Please help!!

Edit: Ok, so I found a way to save the data. But, it saves all the values as one? What is happening here?

7 comments

0

You can't store Color3 or Vector3 (not sure about material), you can convert those values to ints before saving

0

how would i convert vector3 to an int val

0

convert it to a strings instead, for your case strings would be easier, use JSon

0

Vector3.X, Vector3.Y, Vector3.Z

0

ok it doesnt work when i load the build. apparently when i save the table, it takes all the values and adds them all up? why is that?

0

I need to see the save script

1 answer

✓ Accepted answer

The issue isn't actually the dictionary- it's the contents. DataStores are effectively JSON tables, so they can only store numbers, booleans, tables, and strings. You could fairly easily store the Vector3s and Color3s as arrays/dictionaries like

local vector3 = {
	X = myVector3.X,
	Y = myVector3.Y,
	Z = myVector3.Z
}

local color3 = {
	R = myColor3.R,
	G = myColor3.G,
	B = myColor3.B
}

If you found this answer helpful, do mark it as one.

1 comment

0

It kind of works, but when i load the build, it prints X cannot be assigned to [blank]. What is happening here?

This discussion is preserved as it was. New answers, comments, and votes are closed.