UpdateAsync Giving out an Error

Hey there everyone,

Recently I was developing a module for my inventory system, I’m not very experienced in things like DataStores so I recently ran across these errors here:

This is my function for saving the Data:

function InventoryContainerMeta:Save(Player: Player)
	print(self)
	InventoryDataStore:UpdateAsync(Player.UserId, function(oldInventory)
		return self
	end)
end

what self prints out:
image

I’m not sure why this error happens and help would be greatly appreciated,
thank you!

1 Like

I’m not the most qualified to provide a response here, but that error is probably occurring since function(oldInventory) is not or is not set to a number, string, boolean, etc. DataStoreService can only save those. I’d check to see whether function(oldInventory) is of a different class than those.

Hope I helped somehow?

the oldInventory is {__Type = “InventoryContainer”}

You can’t save Instances in a Datastore.

“How can i save what’s in my inventory?”

Serialize.

You can add IDs onto items and save those, and load the parts from those IDs saved in your Datastore.