I was writing a DataStore system earlier, then I got a error showing :
DataStoreService: CantStoreValue: Cannot store Dictionary in data store. Data stores can only accept valid UTF-8 characters. API: SetAsync, Data Store: PlayerData
This problem occured when I’m writing the SetAsync() function, here is part of the code for reference :
function DS:SaveData(plr : Player)
local AD = plr:WaitForChild("AvatarData")
print({AD.HeadColor.Value}) -- For debugging, everything was normal
-- The problem should be here
local data = {
["AvatarData"] = {
-- The Color3 values are converted to an array for saving
-- I don't think there are problems here though
["HeadColor"] = {AD.HeadColor.Value},
["ArmsColor"] = {AD.ArmsColor.Value},
["TorsoColor"] = {AD.TorsoColor.Value},
["LegsColor"] = {AD.LegsColor.Value}
}
}
for i = 1, 10 do
local success, data = pcall(function()
return PlayerData:SetAsync(plr.UserId, data)
end)
if success then
return
else
output(warn, "Failed to save data for "..plr.Name..", retrying, attempt : "..i)
end
end
end
You are attempting to save a color value, datastores can only save tables, booleans, numbers and strings. You could convert the color to hex using :ToHex() and save it like that.
That is probably causing the issue could you try removing the index ([1] in this case) and try again? Also converting to Hex would be much more easier.
Just realized, you are directly setting these from a Color3 value am I correct? If so this won’t work, try converting them to strings or hex. If you are using a string value for this, then there is likely another issue that is unrelated.