Datastore issue

Hey everyone thank you for your time.

Heres the problem.
When player joins Im saving into a datastore something like this:

	local data2Save2 = 
			P01 = {Val1 = "a", Val2 = "b"},
			P02 = {Val1 = "c", Val2 = "d"}

When player joins again, Im reading that datastore and saving that data into a module table

Players_DATA.InGame = {} -- Module table
-- This is done when reading the datastore, creates a key based on the player id
-- and place the datastore data into that dictionary, "looks like this"
Players_DATA.InGame[player.UserId] = "The data gotten from Datastore"}

When I take that module table and try to save it again into a datastore, it says I cant store a dictionary.
DB:SetAsync(ply.UserId, Players_DATA.InGame[player.UserId])

I made this process lot of times before, I mean, reading a datastore, saving that on a module table, letting player to update the values into the module table while playing, and when player leaving using that module to overwrite the datastore of the player, always works, but this time is not, the only difference is that this “dictionary” is a little bigger than previous ones I used, and I have more keys into the module table, but, Im accessing the right one I wanna save.

I know its a dumb question, but, what am I doing wrong?

Is there an error message? If you’ve done this before (and I think I’ve done similar) it seems to probably be a bug somewhere in this implementation, could you share the code?

1 Like

The only error is this one:
not saved 104: Cannot store Dictionary in data store. Data stores can only accept valid UTF-8 characters.

I could bring the code, but its a lot and doing more stuff around the issue.
I could bring the important parts, but, Im sure the original post contains the important.

But yup, maybe Im saving into the module something incorrectly… Thats the only thing I can imagine

That errors looks like you’re trying to save an invalid string, maybe try reviewing all strings that you are trying to save?

1 Like

yup, Im printing everything before perform any saving, update etc.
Before trying to save into datastore Im printing the table to save, and its the right one, and its exactly the same as when player joined and got it extracted from player datastore, its the same as in the module too, and the right one when trying to save into datastore, but still, same error

Are you storing strings? I would assume so and if so, where are the strings from? The error is in a UTF-8 encoded string I believe

1 Like

Im storing a table like this one, the first time is “hardcoded” and it gets saved normally

local data2Save2 = 
	P01 = {Val1 = "a", Val2 = "b"},
	P02 = {Val1 = "c", Val2 = "d"}

Its just the same table at the beginning, on every print, it got saved first time into datastore, then readed from datastore after some time and stored into a module for some time, then tried to save it again into datastore and thats when error occurs

ah, sorry, I misunderstood, that is definitely a weird issue, just to make sure, nothing else reads or writes to the module?

1 Like

yup, theres other functions that writes into the module, but Im not using those functions, just directly into saving cycle testing, at the end before trying to save its printing normally, as it was since the beginning.

Im creating another place in order to test it carefully, just the cycle

sounds good, also, are you storing Instances? heres a similar issue or (although the second one doesn’t have a solution)

1 Like

also, according to, it appears you can’t store “mixed” tables
(in their example)

local a = {1, ['1'] = 2}

both indexed and hashed elements

1 Like

I tested it in another place and works great… But I deleted a step on the edition of the module. Im reading a humanoid description and saving the IDs in some parts of the table that is on the module. By disabling that step the table hierarchy is saving perfectly as it should do… seems that Im breaking somehow the “normal table” when editing it and adding the HumanoidDescription ids…

oh no problem, Im not mixing indexes. “properties” etc, Im messing something during the edition of the table gotten from datastore, the weird thing is both tables looks exactly the same…

so the issues is in adding HumanoidDescription ids to a table? Could you share the code for that maybe?

1 Like

When disabling this line, works normally.
I guess Im not saving proper data when using currentDesc[a]
Players_DATA.InGame[tostring(ply.UserId)]["Av_Presets"]["P01"]["HumData"][a] = currentDesc[a]

ohh!! great, yup, that was the issue… now works great, sorry for making you waste time… I turned all values gotten from the HumanoidDescription into tonumber() and now datastore saves normally… oops sorry :v

1 Like

no worries at all! best of luck on your project!

1 Like

The numeric properties of ‘HumanoidDescription’ instances are already of the number type.

yup, but BodyPartColors is a Color3 instance, so its not possible to save it on a datastore if you dont convert those values into a table. I was not aware of that

Passing a ‘Color3’ value to the tonumber global function returns ‘nil’.

print(tonumber(, 0, 0))) --nil

You’d need to index the color’s ‘R’, ‘G’ and ‘B’ properties and store those instead.