DataStore Error - 104: Cannot store Dictionary in DataStore

I am receiving an error with saving a player’s inventory to a DataStore. My error is 104: Cannot store Dictionary in DataStore. According to the Datastore Errors page (also, can Roblox decide on DataStore vs. Datastore?), error 104 has to do with trying to store too large of an object in the DataStore. But that limit is massive, and I was very confused as to how I could have possibly hit that. So I decided to encode my tables to JSON and print that result just to see how large they were getting, and that has left me even more confused. Here is the JSON’d table that is causing problems:

Exactly as JSONEncode returned it
{"EquippedItems":{"ItemType_9":[{"Metadata":{"VertexColor":null},"ItemID":"{52444A68-DB71-4806-991D-151EB986D1E7}"}]},"ItemType_9":{"{52444A68-DB71-4806-991D-151EB986D1E7}":{"NumberOwned":1},"{69AECD51-0212-4249-9EE5-1CD6E61CE0B7}":{"NumberOwned":1}}}
Prettified version
{
    "EquippedItems": {
        "ItemType_9": [
            {
                "Metadata": {
                    "VertexColor": null
                },
                "ItemID": "{52444A68-DB71-4806-991D-151EB986D1E7}"
            }
        ]
    },
    "ItemType_9": {
        "{52444A68-DB71-4806-991D-151EB986D1E7}": {
            "NumberOwned": 1
        },
        "{69AECD51-0212-4249-9EE5-1CD6E61CE0B7}": {
            "NumberOwned": 1
        }
    }
}

This string is way below the 260,000 characters allowed according to this wiki page.

So I’m at a loss and would really appreciate any ideas anyone may have. :slight_smile:

1 Like

Do you have any code samples to go off of?

The error seems to imply that you are attepting to store a dictionary (a type of table) in the datastore

Have you tried saving the JSON encoded string? That could solve your problems.

I’ve already open-sourced all the code :slight_smile: You can get the component here. For the record though, here is the specific set of lines that are causing the problem:

self._datastore:UpdateAsync(key, function(existingData)
	return serializedData
end)

It does - but I know for a fact that storing dictionaries is fine. I don’t think I’ve ever used DataStores for anything other than storing dictionaries.

I have not yet. I easily could, but I’d like to first see if I was doing something wrong and save that as a last resort.

the prettified version is invalid

"{69AECD51-0212-4249-9EE5-1CD6E61CE0B7}": {
            "NumberOwned"
}

should be

"{69AECD51-0212-4249-9EE5-1CD6E61CE0B7}": {
            "NumberOwned": 1
}

regardless, when i tested this

local Data = [[{"EquippedItems":{"ItemType_9":[{"Metadata":{"VertexColor":null},"ItemID":"{52444A68-DB71-4806-991D-151EB986D1E7}"}]},"ItemType_9":{"{52444A68-DB71-4806-991D-151EB986D1E7}":{"NumberOwned":1},"{69AECD51-0212-4249-9EE5-1CD6E61CE0B7}":{"NumberOwned":1}}}]]

game:GetService("DataStoreService"):GetDataStore("test"):SetAsync("hi",game:GetService("HttpService"):JSONDecode(Data)) <- turns the data into a table

it didnt cause any errors

There is some code over here that may be useful to you in diagnosing the issue:
https://devforum.roblox.com/t/how-can-i-find-the-location-of-userdata-in-my-tables/98377/4

this

I think i found the solution from this

you see the vertexcolor is null right?

thats the json turning it from a userdata into null so it can be stored

The VertexColor value is a UserData value that cannot be stored in datastores

1 Like

You’re right!! Thank you! I don’t know how I managed to miss that.

1 Like