How can I save inventory and save the order of the hotbar / toolbar of a player?

The title basically explains everything.
I have two questions.

  1. What is the best way to save a player’s inventory?
    and
  2. How can I save the order of the hotbar/toolbar so a player doesn’t have to constantly rearrange it when they rejoin?

Any help is greatly appreciated!

2 Likes

Save the players data using Datastore service. There are modules that make it very easy to implement a secure and reliable datastore system (such as Datastore2 and ProfileService). I recommend ProfileService as it has session locking.

As for how you would save the order. Just have a dictionary of the players currently equipped items and their designated slot.

E.g:

local MyEquippedItems = {
    Slot1 = "Banana";
    Slot2 = "Sword";
    Slot3 = "Gun";
    -- etc
};

When the player joins → access the datastore and load the players weapons into the correct slots

1 Like

How exactly would I put X item into X slot in the hotbar?

Are you using roblox default toolbar?

1 Like

Yes I use the roblox default toolbar.

As far as I know there is no hard way to say “tool 1 goes in slot 1” and so on. However what you could do is simply loop through the list of items using a for loop → Make sure the list is in order (or that you’re looping in order) and parent them one by one to the toolbar.

Roblox by default should equip the first tool parented to the first slot, second tool parented to the second slot, and so on.

1 Like

Imagine you have 2 tools, Handgun and Classic Sword, if you set the parent of Handgun to Player.Backpack after Classic Sword, Handgun will appear in the first slot (if you don’t have tools yet) and Classic Sword in the second slot, but to save the tools order idk lol, maybe learning som about CoreGui will be useful for you.

1 Like

Oh yeah I didn’t realize that theres no way to actually determine what is in what slot after a player arranges their inventory. I may have to resort to a custom inventory system.

Studio Settings → Studio → Show Hidden Objects On Explorer = on, with that you will be able to see “CoreGui”, which works like All client’s PlayerGui if i’m not wrong.

lol

Not very sure if that will work but try!

2 Likes

That works perfectly. Didn’t know you could do that! Thank you!

1 Like

Np!, i didn’t expect that it worked, btw you should try if it works correctly with 2 Players, good luck!

Btw i was trying to make this and i helped myself lol.

1 Like

update on this solution, it actually does not work.
Core Gui cannot be tampered with you cannot even check the toolname for some reason even if your not actually changing anything which is pretty stupid. I am still actively looking for a solution to get the hotbar order of a player.

2 Likes

still no authority to read the hotbar, 3 years later…

1 Like

I’ve been using this. I should probably mark it as a solution as I imagine this problem is frequented.
This is basically a copy of the backpack system without making it apart of the core gui. The functionality and appearance are the exact same but the difference is you can edit the code and actually read the hotbar and inventory data.

This has been a solid workaround for me over the years. Hopefully they actually let us read it though one day lol.

I shouldn’t have to fork the backpack system just to have saving hotbars.

I made my own backpack system which acts just like the roblox one and saves all tools but I would still rather use the default backpack so that new users are accustomed to it.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.