So, I need help with a script that i worked on and it a datastore script so im not the best at doing it. I’m new to this devform and never posted a topic so I usually rely on other devforms or youtube videos. Also, the code I worked on is a code that I followed from this one youtuber called WilleRBX
-
I’m trying to make this script work but I cant fix this one error.
-
So the issue is that whenever I play the game it normal but every time I leave this one error popup in the output and it is
DataStoreService: CantStoreValue: Cannot store Dictionary in data store. Data stores can only accept valid UTF-8 characters. API: UpdateAsync, Data Store: DataStorage1 (x22) - Studio
-
I tried
This is the a piece of the code I worked on.
local function save(player)
local UID = player.UserId
local key = "Player_"..UID
local rolls = player.leaderstats.Rolls
local equippedChance = player.Inventory.EquippedChance
local inventoryTable = {}
for i, chance in ipairs(player.Inventory.OwnedChances:GetChildren()) do
inventoryTable[chance.Name] = chance.Value
end
local dataTable = {
Rolls = rolls,
OwnedChances = inventoryTable,
Inventory = {
EquippedChance = equippedChance,
}
}
print(dataTable)
local success, returnValue
repeat
waitForRequestBudget(Enum.DataStoreRequestType.UpdateAsync)
success, returnValue = pcall(dataStore.UpdateAsync, dataStore, key, function() -- This is the part where the error was coming from.
return dataTable
end)
until success
end