DataStore un-readable error

Output: 08DC5B35F5F3A88D.0000000002.08DC5B3602E58DAE.01

Code:

	local Inventory = {
		["Item"] = Player.leaderstats.Rolls.Value,
	}
	local Success, Error = pcall(function()
		return datastore:SetAsync(Player.UserId.."Inventory", Inventory)
		-- Setting the data for inventory for the player
	end)
	if Error then
		warn(Error) -- Showing there was error (Can also keep in log to fix)
	end

Is that’s ok?!?!!

you need to encode the table to json before saving it in a data store, and when getting the saved data you need to decode it using game:GetService("HttpService"):JSONDecode(datafromdatastore)

local Inventory = {
	["Item"] = Player.leaderstats.Rolls.Value,
}
local Success, Error = pcall(function()
	local JSONData = game:GetService("HttpService"):JSONEncode(Inventory)
	return datastore:SetAsync(Player.UserId.."Inventory", JSONData)
	-- Setting the data for inventory for the player
end)
if Error then
	warn(Error) -- Showing there was error (Can also keep in log to fix)
end

Why does a datastore need to be json? I don’t get that part maybe I am missing something.

well you need to only encode to json when youre saving tables because tables outside of the scripts are just their memory adresses (random numbers and letters) which you cant convert back to the original table with all the values, but when you encode it converts the table to a json string that keeps all of the values and can be converted back to the original table
image

Still this error: 08DC5B35F5F3A88D.0000000003.08DC5B38575C4B8F.01

the interesting thing is that this “error” is changing. it also seems to be unrelated to the table, because after changing the type from the table to the variable, the error continues to exist

The first value returned from datastore:SetAsync is an identifier used for versioning, which is then assigned to your Error variable.

You need to first check that Success is false, and when it is false, you can warn(Error)

You also don’t need to JSON encode or decode anything as that’s already done for you on the backend.

you dont return for setasyncs in datastores you only do it in getasyncs