Adding and removing from tables and saving them in datastore2

So I’m trying to save an inventory, and I’m using datastore2 to do it. I’m gonna save tables that look like this (without the quote):

local inventory = {
	["Item"] = 2, --the player has 2 of this same item
	["OtherItem"] = 1
}

How would i add or remove objects from tables and save them? (btw i’m new to datastore2)

im sorry that i am too lazy to tell you the whole thing, but you can use metatables (i hate metatables) to accomplish your goal. metatables are essentially special tables that define custom behaviors for other tables by using metamethods, allowing for operations like custom indexing, arithmetic, and method overriding

Looking into metatables, they actually seem pretty helpful for what I’m trying to achieve, so thanks!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.