Datastore issue

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 https://devforum.roblox.com/t/cannot-store-dictionary-in-data-store-data-stores-can-only-accept-valid-utf-8-characters/367894 or https://devforum.roblox.com/t/cannot-store-dictionary-in-data-store-data-stores-can-only-accept-valid-utf-8-characters/1062157 (although the second one doesn’t have a solution)

1 Like

also, according to https://devforum.roblox.com/t/datastore-concerns/515952/7, 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(Color3.new(0, 0, 0))) --nil

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

Thats what I said I did, RGB array

The ‘R’, ‘G’ and ‘B’ fields of ‘Color3’ values are already number literals (don’t need to be passed to tonumber).