Open Sourced Inventory/Backpack system

Is this XBox and Touch Device compatible?

3 Likes

This is nice and helpful. Many players could make use of this

1 Like

I’ve had that warning before. I don’t remember the exact details, but I do remember that putting in a wait() before trying to change the parent made the warning go away. Something to do with trying to change the parent on the same frame that roblox code is trying to set it I think.

1 Like

It’s not that hard to edit it to be XBox or Touch Device compatible, but by default no.

In regards to your Side Notes section involving the reparent warning – This is easily resolvable.

In case you are unaware – This “unexpected parent change” warning is thrown to prevent event spamming to flood the event queue.

One example of code that this warning protects against is:

local p0 = workspace.Object0
local p1 = workspace.Object1
p0.DescendantAdded:Connect(function (d)
    d.Parent = p1
end)
p1.DescendantAdded:Connect(function (d)
    d.Parent = p0
end)

Parent something to p0 or p1 and you suddenly have something spamming the ever living crap out of Roblox’s backend event system with DescendantAdded event calls.

When this warning displays, Roblox automatically yields until the next event pipeline flush (effectively identical to calling wait()).

If I read your code correctly, you can resolve this issue by going to line 101, adding a newline into that condition, and before calling removeToolFromSlots(tool), add wait(). The code here runs on AncestryChanged (when the parent is changed) and removeToolFromSlots() instantly changes its parent again.

5 Likes

Where does the ModuleScript go?

Anywhere the LocalScript can access it.
In the example GUI provided, I simply parented it to the LocalScript itself.

1 Like

Should I make a version of this that doesn’t use ObjectValues?

  • Make a version of this that doesn’t use ObjectValues
  • No, using ObjectValues is nice because there’s no need to memorise custom syntax

0 voters

It would basically be the same thing but with tables instead of a folder

1 Like

I’ve fixed the unexpected parent change bug and another minor bug.
It was happening because the custom Backpack and the default Roblox Backpack were conflicting.
If anyone finds any bugs please DM me.

With the slot values supposedly in order, wouldn’t they just go from Eight to Zero straight down? Aswell as the “Equal” NumberValue, what is that for?

Thanks for releasing this :slight_smile:

No


You might be confused because Roblox Studio’s explorer arranges the values alphabetically, but it’s the order in which u insert the objects that matters. I’ll admit this isn’t the best way to do ordering, but it’s pretty simple/intuitive. I don’t see it breaking any time soon. It’s mainly for knowing which slot to auto-assign tools to. When a tool is given to the player, it goes to the first available slot in this order.


The names correspond to whatever Enum.Keycode you want for activation (I said this in Setup step 2).
By naming it “Equals”, you bind that slot to Enum.Keycode.Equals
It is shown as slot 12 on the GUI.

For example, if you were to rename it to “Tab”, then the activation key would become the Tab key.

1 Like

In you next inventory system could you teach us how to implement touch and controller support - I am familiar with enum.Keycode but I have no clue on how to scroll through the inventory using LB and RB

4 Likes

How do I edit this to a state where when a new tool is added, the oldest tool is removed?

The same way you would do that with the default inventory.
Something like this

Player = game.Players.LocalPlayer
Backpack = Player.Backpack

oldestTool = Backpack:GetChildren()[1]

Backpack.ChildAdded:Connect(function(addedTool)
    oldestTool:Destroy()
    oldestTool = addedTool
end)
2 Likes

Hi there~ @dispeller

Thank you for sharing your creation with us, this is very interesting stuff.

Would you kindly create a link to Source code (preferably Github and/or Pastebin) for people who want to read the source but don’t have any access to a PC or maybe want to contribute to the source

no

jk lol
sure thing
https://pastebin.com/raw/EPzEeLQf

3 Likes

How would I make it so that the inventory numbers would reset when a tool leaves the inventory? Right now I’m using a menu to choose a loadout and when the loadout is chosen, any items in the inventory are destroyed. The number key for the inventory doesn’t reset, Ex. I have 2 tools and reset the inventory with another tool, instead of becoming 1 the tool can be equipped with 3

Just put a delay before giving the tool. Something like

for i,v in ipairs(Player.Backpack:GetChildren()) do
    if v:IsA("Tool") then
        v:Destroy()
    end
end

if Player.Character and Player.Character:FindFirstChildOfClass("Tool") then
    Player.Character:FindFirstChildOfClass("Tool"):Destroy()
end

wait(2)

for i,v in ipairs(Tools) do
    v:Clone().Parent = Player.Backpack
end

untested code

How can you save tool positions when dying and stuff?

Untitled
its a cool inventory system, but can i suggest about could u make it more the inventory system look like in the r6 dance Roblox game
thx