DataStoreService error problem: API: UpdateAsync

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

  1. I’m trying to make this script work but I cant fix this one error.

  2. 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

  3. 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
1 Like

I assume player.Inventory.EquippedChance is an instance, you probably wanted the .Value of that if it’s a value, otherwise that won’t work

1 Like

Ok, im gonna try that first. I’m gonna come back to tell you if it work or not.

Soooo, It worked and I forgotten to add Value for equippedchance and rolls variables