How do I make an inventory script that stores data when you leave the game?

what does it do? can you explain?

It takes all the tools from your backpack and stores them in a datastore. When you join back the tools get cloned from the Tools folder and put inside of your backpack again.

does this DataStore work with large amounts of players at once, or is it one script per player?

Ohh, I understand what you’re trying to do now.
You want to store a part instead of a tool.

Anyways, you can use that script for storing parts aswell, here’s how:

  • Create a Tool.
  • Create a Part inside the Tool named Handle.
  • Make sure to not Anchor it.
    This will create a tool you can equip which will be a part.

so this means that i have to make a tool and parent my part into the tool?

Yeah. Like this:
Screenshot 2024-11-03 160256

alright, but what if i dont want it to be a tool, and instead just store it as is? do i still need the tool?

You can do it without the tool.
But for that you will have to loop through your custom inventory instead of the Backpack.

i think thats where my issue comes in, since i dont know how to make a custom inventory :sweat:

Well you can search on how to make a custom inventory system, it’s really not that hard.
For example, you can put all your parts inside a table and then put them inside a ScrollingFrame that has a UIGridLayout with a LocalScript.

and what do i put in the local script? (i apologise if im asking a lot of questions right now, im still new to scripting and im triyng to learn new things as i progress)

DataStorage in the way you intend to use it is player specific.

So as in like, it is able to hold a large amount of data at once?

local player_items = {} --you need to add something to this table once they earn a part (like the part's name)
for i,v in player_items do
    if v ~= nil then
        local clone = button:Clone() --button would be your slot for the part
        clone.Text = v --if you set it to the part's name
        clone.Parent = gui --gui is your scrollingframe
        clone.Activated:Connect(function()
        --here we would do something once they press the button but thats not important for now
        --we would have to find the actual part inside a folder
        --also i dont know what you want to do once the button gets clicked
       end)

Of course this doesn’t include updating the list when a part gets added/removed, but for that I recommend to just watch a tutorial on how to make a custom inventory system.

alright, thank you for the help so far. im going to work on it tomorrow, as its getting late and my computer is about to die. i truly appreciate your effort for trying to help me

1 Like

The information should be in that video I provided you but you can essentially store data by ID and key.

however much you WANT to store is up to you, just don’t call datastorage too much or you’ll get into issues with roblox.

1 Like

i just realised i needed a “backpack” system, and i thought that inventory meant the same as backpack. i will try to find youtube tutorials about it, thanks for the help so far and i think im gonna close this post

1 Like