How to make an Inventory System that is simple, reliable, and easy to modify

Hello, I am a beginner looking to try my hand at creating an inventory system that will keep players’ items safe until they are ready to consume them for various activities. This inventory should be saved if they player leaves and joins again later.

I have learned about the DataStore and the popular DataStore2 module as well. I am unsure which one best fits what I want to do here. I was thinking of having a single array with numeric indices and string ID value that represents an item. Scripts would append to and remove from this table as the player does various things to consume items. The entire table would save before they leave and be called when they join again. I’m not sure this is the best idea though, it seems inefficient especially once there are many copies of the same item in the inventory.

Currently, I only have plans to make an inventory that can hold “materials”, like coal or wood, that are static and only consumed when a player wishes to perform a certain action, such as crafting a torch. Perhaps I would want to add gear, pets, or other items to my game later that would be more than just a static resource. I’m not sure how I could write an inventory system to accommodate more complicated items like this. Perhaps I should not do that and keep the materials inventory seperate from tools and pets.

11 Likes

Can we please see what you got so far?

I don’t have anything of substance yet. At the end of the day, I know the inventory is going to be a table of values that is associated with a player. This table needs to be changed dynamically while the player is in the game, saved when they leave. It will also be accessed when they join and by the client and server when needed. I just don’t know how to start with all this, like what the best practices are and resources I should read before embarking on this project.

1 Like

As for Datastores here is a very good video (in my opinion) https://www.youtube.com/watch?v=at9Yhjt572c

the code in it seems to be very clean at least compared to other videos I’ve watched

2 Likes

You should have used the search bar, there are many posts on how to make inventory systems, and help you understand them step by step. With the link I provided (the word in blue) you might find many useful posts that could help you. If you do not want to scroll through all of the post made there, (which you should cause it’s probably better) I’ve picked out a few that might help you the most:

this post by @dispeller
and

this post by @rangblade

Like I said, there is more than just these two, but these will probably help you the most! If you want to find more post about how to make inventory systems, just use the links and/or search bar. If you use the search bar, don’t forget to use advanced search. If you don’t know how to do that, here’s a quick summary:

How to find better posts

Click the search bar, you will then see a bar that says “Advanced Search” below the text box. Click it and look for the word “Categorized”. The click it and click any of these topics:

The resources tab is the way to go if you want just a uncopylocked version, but if you want someone to explain it, then I suggest scripting support.

I know I got a bit off-topic, but this could possibly help you! :smiley:

9 Likes

I tried searching initially but I could not find a general post about inventory systems. Perhaps I should be using google? I am also unfamiliar with advanced search. How do I use it?

1 Like

There is a bar right here:

Click that in the post above you, and you can see. And the links I provided could probably help you. Click the ones in blue.

i dont see anything in the blue link you gave me

You have to click the blue text in order to go to the link.

I opened it in a new tab and it worked. Or maybe I was just being dumb, sorry. it works thank you so much.

1 Like