Running into Database Trouble

I wrote a firebase to roblox and vise versa script. The point i’m at now is, when I save the data its saved as a table, but when I call it back firebase converts to to a dict.

here is the output:

Error is because its expecting a table, but its getting a string. Is there a way i can convert this dict to a table?

Would be great if you showed us the code where it errors.

	local Invt = Inv:Load(Player)
--	Inv:Add(Player, "Dog", 5) -- Testing the save
	for Index, Items in pairs(Invt) do
		print(Index, Items)

function Inventory:Load(Player) -- Load player Inv when join
	local SaveInv = Store:GetAsync(Player.UserId.."Inv", Inventory)
	local SaveInv = FireStore:GetAsync("Test-2".."/")
	if not SaveInv then SaveInv = New(Player) end
	Inventories[Player.UserId] = SaveInv
	return Inventories[Player.UserId]

Seems like “Inv” is a string, not a table?
And what is :Load() anyways? Never seen it in DataStore2 I think.

Im not using datastore 2. im using my own system.

:GetAsync() only has one parameter, not two.
You should also wrap your calls in a pcall().

I don’t see anything erroring on line 7 as specified?

1 Like

Maybe something is in error with your system.

It would appear that your load method returns a string (perhaps JSONEncoded)? Which can be turned into a table - assuming that you have a proper encoding format - using JSONDecode.

1 Like