So I’ve recently been working on a shop and inventory system for my game but I need help getting the inventory to save using DataStores. (In the Script for the DataStores, I currently only have the part that gives you the Folders that are used for the player’s inventory)
Example item:
Every Item has the same template with each and every Value being required to save and load with it or the Inventory will break.
If anyone has a solution it would be appreciated if you can help out.
You would need to convert every item in said players inventory into 1 big table. You also would need to save some sort of ID for each item, along with the number owned, and possibly other factors based on your items. you could use the name but I’m not sure if that works 100%.
Once you have your table, you would datastore the table, then whenever loading data, you would go through the table and create an item in their inventory. Like
for i,v in pairs(table) do
local new = game.ReplicatedStorage.Items:Clone() -- item saved, just a template location
new.Parent = player.Inventory
end
I’ve never really put this in but, I had 4 different folders based on the Value inside “Class”, would there be a way to implement that in?
Also for the ID, since every one of these items can easily get to these items just from the name of the first value, can I just use the ID for the item and having it change when it’s equipped?
You would put every item into a folder most likely in ReplicatedStorage, then use that table to find every item in their inventory, and clone it to them