DataStore not working properly even though it should?

Hello! :wave:
I was trying to save multiple items for my game, therefore I stored them in a folder inside of the player that stored every item the player owned.

when the player left, I did this, which saved them all inside of a table

local inventory = {}

		for i, v in pairs(player.ItemFolder:GetChildren()) do
			if not table.find(inventory,v) then
				print(v)
				table.insert(inventory, v)
			end
		end

and then, using the magic of data stores, I did this

DataStore:SetAsync("Inventory"..player.UserId,inventory)

when I try printing everything, it seems to be working and everything inside of the folder to also be in the table, though when I do this and try to get the table when the player rejoins, the table doesn’t have the things I saved

if inventory then
			print(inventory) -- this prints only things that I've saved before
switching to this method (of saving when player leaves)
end

the reason I’m saving when the player leaves is because I need to save quite often and that exceeds the DataStore limits

Studio testing with datastores is often problematic. Do you get the same results on the normal client?

Haven’t tried that, let me go check

Doesn’t seem to work, it’s the same thing on the normal client too

You cannot save instances through data stores. You can save the tool’s name in string form then load it according to the name that matches the corresponding tool.

Can you even read for god’s sake? I literally never said I’m saving a tool, just said I’m saving items in the form of a table, as far as I’m aware, I can use tables for saving data.

It works perfectly fine if I save it normally every time the player buys an item, but this happens too often and breaks the limits of the DataStore.
For some reason, when saving it this way, it does not work.

Just because you’re saving it in a table, doesn’t mean you can save anything. If there is an instance inside the table, of course the table/instance won’t save.

Oh my goodness, I am so incredibly sorry, I just noticed I forgot to do v.Name and instead I wrote just v. I wrote .Name on the other DataStore so that was why that one worked. Thank you for letting me know this and I am truly sorry lol

Read before you do, that’s one common mistake.

1 Like