Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to create a inventory system to store models?

I am creating a game where you can buy models and are placed into your inventory. Once placed inside of you inventory (preferably inside a gui) you can activate my grid placement system using the model that is stored inside of your inventory. Once placed it will be removed from your inventory. I have the grid placement system down and I am trying to figure out if their is a way people can buy from a shop and the model is placed into inventory then can be used by my placement system. Any replies helps even if it is basic. Thanks for your help!

1 comment

0

Provide an example script?

1 answer

✓ Accepted answer

-- ISN'T OWNED BY ME

So lets say we have an inventory table named “Inventory”

Inventory = {};

This inventory table will contain everything in a users inventory as well as its data. Now you want crafting, so we can add materials and items in to this table. Now it will look something like this.

Inventory = {
   Materials = {}, -- All of our materials will be stored here
   Items = {}, -- All of the users items will be stored here
}

Now its as simple as learning how to read and manipulate your table properly. For example if each item has specific data then you could make a table for that specific item in your table.

Inventory = {
   Materials = {}, -- All of our materials will be stored here
   Items = {
      WoodenAxe = { -- Our wooden axe is the item, you can add as much data as you'd like in here.
         Amount = 1, -- We have one wooden axe
         Durability = 100, -- Its durability is 100
      }
   }, -- All of the users items will be stored here
}

Now you have a basic inventory set up! A reminder, this table should ALWAYS be set up on the server!

To get everything in a users inventory simply use RemoteFunction in order to return the users inventory, you can use a loop and then display it in a UI.

Crafting? Check all of the materials/items a user has and then compair it to your crafting recipes. If a user can craft something then you could put all of the items a user can craft in a table (on the server) and return it. Once again cycle through all of the items a user can craft and put them up for display.

Security is key when it comes to systems like this, so when a user fires a RemoteEvent in order to craft and item make sure you check to see if the user can actually craft that item before giving it to them.

This discussion is preserved as it was. New answers, comments, and votes are closed.