Luau Scripting

Fix DataStore Error 104 "Cannot Store" in Roblox Studio

Why Roblox shows DataStore error 104 "Cannot store Dictionary/Array in data store", how to find the bad value, and how to save Instances, Color3, and Vector3.

Fix DataStore Error 104 "Cannot Store" in Roblox Studio
On this page
  1. What “Cannot store X in data store” means
  2. Step 1: Print what you’re actually saving
  3. Cause 1: A Roblox object inside the table
  4. Cause 2: The wrong argument from a remote
  5. Cause 3: Strings with invalid UTF-8
  6. Cause 4: Mixed or broken tables
  7. If it still doesn’t work
  8. Related guides
  9. Sources

Roblox DataStore error 104 shows up when you try to save something a data store can’t hold. The message usually reads like 104: Cannot store Dictionary in data store. Data stores can only accept valid UTF-8 characters., which is confusing, because dictionaries are allowed. The real problem is almost always one value hiding inside that table. This guide shows how to find it and how to convert it into something you can save.

What “Cannot store X in data store” means

The Creator Hub error table lists code 104 as CantStoreValue, with the message “Can’t store X in DataStore” and the explanation that the value of type X didn’t serialize. Saving to a data store turns your value into a text format first. If any part of it can’t be turned into text, the whole save fails.

You’ll see a few versions of the message, depending on what you were saving:

Message you seeWhat X refers to
Cannot store Dictionary in data storeA table with named keys, such as { Coins = 10 }
Cannot store Array in data storeA table with numbered keys, such as { "Sword", "Shield" }
CantStoreValue: Cannot store in data storeSame error, sometimes shown without a type name

The key point is that Dictionary and Array describe the outer table, not the problem value. Plain tables of strings, numbers, and booleans save fine. Something nested inside is breaking the save.

Don’t confuse it with its neighbors in the same table of error codes:

CodeNameMeaning
103ValueNotAllowedA bad update function returned a value of a type that isn’t allowed
104CantStoreValueThe value couldn’t be serialized
105ValueTooLargeThe serialized value is larger than the per-key limit (4,194,304 characters)

If saving fails with a different message, such as a 403 error in Studio, see how to fix a DataStore that isn’t working in Studio instead.

Step 1: Print what you’re actually saving

Before changing anything, check the value right before the save. A small helper that walks through the table and prints any value that isn’t a plain type will usually point straight at the culprit:

local function findBadValues(value, path)
	path = path or "data"
	local kind = typeof(value)
	if kind == "string" then
		if utf8.len(value) == nil then
			warn(path, "has invalid UTF-8")
		end
	elseif kind == "table" then
		for key, child in pairs(value) do
			findBadValues(child, path .. "." .. tostring(key))
		end
	elseif kind ~= "number" and kind ~= "boolean" then
		warn(path, "is a", kind)
	end
end

findBadValues(saveData)

Here’s what it does:

  • typeof returns the type name, so Roblox objects show up as Instance, Color3, Vector3, EnumItem, and so on.
  • utf8.len returns nil when a string isn’t valid UTF-8, which catches broken text.
  • For tables, the function calls itself on every entry and builds a path like data.Inventory.1, so you know exactly where the bad value lives.

Run it in Studio and read the warnings in the Output window. Remove the call once you’ve fixed the data.

flowchart TD
    A["Save fails with error 104"] --> B["Print the table before saving"]
    B --> C{"What did the check find?"}
    C -->|"Roblox object"| D["Convert it to plain values"]
    C -->|"Bad string"| E["Remove the invalid characters"]
    C -->|"Nothing flagged"| F["Check for mixed keys or a wrong argument"]

Cause 1: A Roblox object inside the table

This is the most common cause reported on the DevForum. Types like Color3, Vector3, CFrame, EnumItem, and any Instance are Roblox data types, not plain values, so they need to be converted before saving and rebuilt after loading.

local saveData = {
	Coins = 250,
	Color = color:ToHex(),
	Position = { pos.X, pos.Y, pos.Z },
	Material = part.Material.Name,
}
store:SetAsync(key, saveData)

Each line swaps an object for something storable:

  • Color3: Color3:ToHex() returns a hex string such as "804000". When loading, Color3.fromHex(saved.Color) turns it back into a color.
  • Vector3: save the X, Y, and Z numbers in a small table, then rebuild it with Vector3.new(p[1], p[2], p[3]).
  • EnumItem: save its Name string, then look it up again with Enum.Material[saved.Material].
  • Instance: you can’t save the object itself. Save something that identifies it, such as the tool’s name, and clone it from a template in ServerStorage when the player joins.

A related mistake is looping over leaderstats or an inventory folder and saving the child objects instead of their .Value. Save coins.Value, not coins.

Cause 2: The wrong argument from a remote

If the table looks fine in your code but the save still fails, check where the data came from. RemoteEvent.OnServerEvent always passes the Player who fired it as the first argument. One DevForum case saved the result of OnServerEvent:Wait(), and the first value it returned was the player, not the data table.

remote.OnServerEvent:Connect(function(player, settings)
	-- settings is the second argument; player always comes first
end)

If the remote handler never runs at all, see why a RemoteEvent isn’t firing.

Cause 3: Strings with invalid UTF-8

The SetAsync and UpdateAsync reference pages both state that any string saved to a data store must be valid UTF-8. A single byte above 127 that isn’t part of a proper multi-byte character makes the save fail.

This usually happens when you build strings with string.char, pack numbers into strings by hand, or compress data into a custom binary format. If the check in Step 1 flags a string, either store the underlying numbers in a table instead or encode the bytes in a text-safe way before saving.

Cause 4: Mixed or broken tables

Data stores save tables in a JSON-like format. The Creator Hub notes for HttpService:JSONEncode describe the same rules that trip people up:

  • A table should use either numbered keys or string keys. If it has both, the array part wins and string keys are ignored.
  • Avoid nil holes in arrays, such as { 1, nil, 3 }.
  • A table that contains itself (a cyclic reference) causes an error.

DevForum reports show mixed tables can fail with 104 or, in some cases, save with parts missing. Either way, the fix is to keep each table one shape:

-- Mixed: numbered and named keys in one table
local inventory = { "Sword", "Shield", Equipped = "Sword" }

-- Split into one array and one named field
local inventory = {
	Items = { "Sword", "Shield" },
	Equipped = "Sword",
}

Number keys used like IDs, such as [1052] = true, are another trap, because they form an array with holes. Convert them to strings (["1052"] = true) and turn them back with tonumber when you load.

If it still doesn’t work

  • Check the size instead. If the message says ValueTooLarge (105), the data is serializing fine but it’s too big. The Creator Hub suggests measuring it with #HttpService:JSONEncode(saveData).
  • Check your data module. If you use a module such as ProfileStore, the 104 error is still about your template or profile data. Run the Step 1 check on the template and on a loaded profile.
  • Wrap saves in pcall. The data stores guide recommends it for every call, so a failed save logs an error instead of stopping your script. If saves fail because you’re sending too many, read how to fix “DataStore request was added to queue”.

A simple habit prevents most 104 errors: keep a single save table made only of strings, numbers, booleans, and plain tables, and convert to and from Roblox objects in one load function and one save function.

Sources

Frequently asked questions

What does DataStore error 104 mean in Roblox?

Roblox lists code 104 as CantStoreValue: the value you tried to save could not be serialized. The type in the message, such as Dictionary or Array, is the outer table that failed, not necessarily the exact value inside it that caused the problem.

Why does the error mention valid UTF-8 characters?

The Creator Hub says every string saved to a data store must be valid UTF-8, and a save fails if a string contains invalid bytes. The same message is shown for other unsavable values too, so a bad string is only one possible cause.

Can I save a Color3, Vector3, or Instance in a data store?

Not directly. Convert them into plain values first: a Color3 to a hex string with ToHex, a Vector3 to a table of three numbers, and an Instance to something that identifies it, such as its name. Rebuild the real objects when you load the data.

How is error 104 different from error 105?

Error 104 means the value can't be serialized at all. Error 105 (ValueTooLarge) means it serialized fine but is bigger than the per-key limit, which the Creator Hub lists as 4,194,304 characters of serialized data.

Related guides