Why does my datastore think my table is a dictionary?

  1. What do you want to achieve? I want to save a table of information about a cars livery (So it can be easily retrieved and updated by the teams owner)

  2. What is the issue? It won’t let me store the table in the datastore.

  3. What solutions have you tried so far? I’ve tried googling what separates the two and I have tried to convert it to a table but nothing seems to be working.

My other (separate) datastore allows me to store different information in essentially a different format. I was wondering if it is because I am mixing 3 types of values (String, number and Color3) but I am not 100% sure.

Example which works (Every value is a string)

local success, errorMessage = pcall(function()
			local GarageInfo = {
				["Driver2"] = v.Driver2.Value;
				["Driver2Number"] = v.Driver2.Number.Value;
				["Driver1"] = v.Driver1.Value;
				["Driver1Number"] = v.Driver1.Number.Value;
				["Owner"] = v.Owner.Value;
			}
			GarageDataStores:SetAsync(v.Name, GarageInfo)
		end)
		if not success then
			print(errorMessage)
		end

Example which doesn’t work (Mixing 3 different values which returns the error screenshotted earlier

local success, errorMessage = pcall(function()
			
			local GarageInfo = {
				["Reflectance"] = v.Livery.Reflectance.Value;
				["BaseColour"] = v.Livery.BaseColour.Value;
				["MainTexture"] = v.Livery.MainTexture.Value;
				["HaloTexture"] = v.Livery.HaloTexture.Value;
			}
			LiveryDataStores:SetAsync(v.Name,GarageInfo)
		end)
		if not success then
			print(errorMessage)
		end

I think I have encountered this same issue before. Try using HttpService:JSONEncode() to convert your dictionary to a string, and then when you load the data back in, use HttpService:JSONDecode() to convert the string back to a dictionary.

For something like a vector3 or color3 value, you have to save it like this:

local Dictionary = {
	["Color"] = {Color3.Red, Color3.Green, Color3.Blue}
}

And to convert this back to a Color3 value when loading your data, do this:

Color3.new(table.unpack(Dictionary.Color))

Hopefully this helps

1 Like