Where can i find a good custom inventory system

Ive been trying to do this for days and im tired of it, i just want a inventory system jsut like the roblox one except it actually works.

The roblox inventory system does not fix the number indexes when a tool is removed. Example:

You have tools 1, 2, 3
You remove tool 2
You have tools 1, 3
THIS is bad

i want this:
You have tools 1, 2, 3
You remove tool 2
You have tools 1, 2

I cant get this working. Ive looked everywhere for an inventory system, ive tried making once myself 3 times with no progress, i dont know what to do. If anyone knows how to either fix roblox’s inventory or make a custom one that actually works, please help me.

So I am also making an inventory system, but it’s not following what you said. So what I suggest you to do is to add and in inventory slots during run time and to change their slot number so that way you can have the slots the way you want. Also use grid layout or list layout.

do you mean like a hotbar system for tools?

if so have u tried searching up “hotbar system” in Community Resources or Community Tutorials? there should be plenty of stuff there for u hopefully!

what u could do is say if u have a frame for each number - eg. 1, 2, 3. u could store an attribute called “ToolNumber” and a boolean attribute called “Removed” to see what tool is which with an allocated value and what tool was removed.

from there u can use GetAttributeChangedSignal on the removed attribute to check when the player has removed the tool and change the tool number attribute accordingly and update the tool number text based on the tool number attribute.

i hope these videos are of any help (-:

Also, maybe store the inventory in a table then keep updating the UI by looping through the inventory. So that way when you remove an item from the inventory and change the position to its index.

1 Like

I made a script that kind of works, although i cant get my dragging system to work. Also i havnt started working on the equpiing/unequipping. I asked 2 scripting friends and neither of them could help.

local dict = {

}

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

local UIS = game.UserInputService
local Mouse = game.Players.LocalPlayer:GetMouse()

local isdragging = false
local dragtime = 0
local mousedown = false
local Hovering = nil
local dragged = false

local function AddIndex(Tool)
	table.insert(dict, Tool)
	local New = script.Parent.Item:Clone()
	New.Visible = true
	New.ItemName.Text = Tool.Name
	New.IndexNumber.Text = #dict
	New.Parent = script.Parent.Hotbar
	New.Name = #dict
	
	New.MouseEnter:Connect(function()
		if not mousedown then
			Hovering = New
		end
	end)
	New.MouseLeave:Connect(function()
		if Hovering == New and not mousedown then
			Hovering = nil
		end
	end)
end


local function Refresh()
	table.clear(dict)
	for _, V in script.Parent.Hotbar:GetChildren() do
		if V:IsA("Frame") then
			V:Destroy()
		end
	end
	for _, V in game.Players.LocalPlayer.Backpack:GetChildren() do
		AddIndex(V)
	end
	print(dict)
end

game.Players.LocalPlayer.Backpack.ChildAdded:Connect(Refresh)
game.Players.LocalPlayer.Backpack.ChildRemoved:Connect(Refresh)

UIS.InputBegan:Connect(function(Inp)
	if Hovering ~= nil then
		if Inp.UserInputType == Enum.UserInputType.MouseButton1 then
			mousedown = true
			
			while mousedown and Hovering ~= nil do
				dragtime += 0.05
				
				if dragtime >= 0.3 then
					isdragging = true
					print("Dragging: "..Hovering.IndexNumber.Text)
					dragged = true
					Hovering.Parent = script.Parent
					game.TweenService:Create(Hovering, TweenInfo.new(0.05, Enum.EasingStyle.Bounce), {Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)}):Play()
					
					local Lowest = math.huge
					local RealVal = 0
					local LowestFrame = nil
					
					for _, V in script.Parent.Hotbar:GetChildren() do
						if V:IsA("Frame") then
							local Diffrence = V.AbsolutePosition.X+(V.AbsoluteSize.X/2)-Hovering.AbsolutePosition.X+(Hovering.AbsoluteSize.X/2)
							
							if math.abs(Diffrence) < Lowest then
								Lowest = math.abs(Diffrence)
								LowestFrame = V
								RealVal = Diffrence
							end
							
							
						end
					end
					
					if math.sign(RealVal) == -1 then
						print("Left To: ", LowestFrame.IndexNumber.Text)
					else
						print("Right To: ", LowestFrame.IndexNumber.Text)
					end
					
					
				end

				task.wait(0.05)
			end
			
			if dragged == false then
				print("Selected: "..Hovering.Name)
			end
			dragged = false
			isdragging = false
			dragtime = 0
		end
	end
end)

UIS.InputEnded:Connect(function(Inp)
	if Inp.UserInputType == Enum.UserInputType.MouseButton1 then
		mousedown = false
	end
end)


Refresh()

This works fine, but id like to be able to drag the items and have them snap to the closest position in between 2 other items. Current issue is that my detection for where to snap the GUI doesnt work. If you want to do further testing:
inventory.rbxm (10.8 KB)

To equip and unequip a tool you have to move the tool from the backpack to the character on the server which results in it being equipped. To unequip you just move the object back the backpack or you could use the humanoid:UnequipTools() method. For dragging UI objects you could use the beta UIDragDetector.

UIDragDetector Documentation: