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.
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.
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:
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:
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?