hi,im struggling with creating the inventory system i don’t what should i use i ve been thinking about useing folders with the main being inventory and its children are categories like weapons , cosmetics…ect and when add an item inside each one i can use configuration or value objects to set the values
or using tables but the thing that is bothers me is when i add an item inside the tables it will look messy
You can use a dictionnary that you save and load on the datastore, then check these values to add or remove items on your GUI. That’s basically how everyone do.
local PlayerData = {
Weapons = {
ClassicSword = 1, -- How much owned
MagicWand = 4,
},
Cosmetics = {
KnightHelmet = 2,
MageHood = 1,
}
}
but what about items with stats , the example that u ve provided shows only a one value for each one
You can customize the dictionnary however you want depending of your game. As for example, if each of your items can have different stats, you could do something like this:
local PlayerData = {
Weapons = {
ClassicSword = {5, 32}, -- level, base damage
ClassicSword = {3, 29},
MagicWand = {1, 24},
},
}
You could also make it so these are the inventory slots
local PlayerData = {
Weapons = {
Slot1 = {"ClassicSword", 5, 32}, -- Item name, level, base damage
Slot2 = {"ClassicSword", 3, 29},
Slot3 = {"MagicWand", 1, 24},
},
}
but this looks a little bit confusing when adding multiple items and besides , some items will have stats that the others dont
Will the item’s stats change? If not, then you can create a folder in replicated storage that stores all the stats for each item. This would mean you wouldn’t need to worry about datasaving stats.