I am working on a wild west game based on a PVP type of fighting style. Regardless I made my very first workable inventory UI. and it looks simple did take a few hours to get it here. Probably gonna end paying someone though for pngs to really make it stand out. regardless this is what I have so far. Would love to hear what you think. I also show the code to see if you guys like what you see. I will also admit I used AI to help with getting me started!
-- Get services
local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")
-- Disable default backpack
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
-- Wait for PlayerGui
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
-- Create GUI container
local customBackpackGui = Instance.new("ScreenGui")
customBackpackGui.Name = "CustomBackpackGui"
customBackpackGui.ResetOnSpawn = false
customBackpackGui.Parent = playerGui
-- Main frame
local frame = script.Parent.MainFrame
-- Padding
local padding = script.Parent.MainFrame.UIPadding
-- Title
local title = script.Parent.MainFrame.Title
-- Header frame
local headerFrame = script.Parent.MainFrame.HeaderFrame
-- Create headers
local headers = {
"Tool", "Accuracy", "Power", "Push"
}
for i, headerText in ipairs(headers) do
local headerLabel = Instance.new("TextLabel")
headerLabel.Size = UDim2.new(0.25, 0, 1, 0)
headerLabel.Position = UDim2.new((i - 1) * 0.25, 0, 0, 0)
headerLabel.BackgroundTransparency = 1
headerLabel.Text = headerText
headerLabel.Font = Enum.Font.SourceSansBold
headerLabel.TextSize = 18
headerLabel.TextColor3 = Color3.new(1, 1, 1)
headerLabel.Parent = headerFrame
end
-- Scrollable container for tool list
local scrollFrame = script.Parent.MainFrame.GunScrollLayout
-- Add a UIListLayout for vertical stacking
local layout = Instance.new("UIListLayout")
layout.FillDirection = Enum.FillDirection.Vertical
layout.Padding = UDim.new(0, 5)
layout.SortOrder = Enum.SortOrder.LayoutOrder
layout.Parent = scrollFrame
-- Add tool to GUI
local function addToolToGui(tool)
local row = Instance.new("Frame")
row.Size = UDim2.new(1, 0, 0, 30)
row.BackgroundTransparency = 1
row.Parent = scrollFrame
local toolButton = Instance.new("TextButton")
toolButton.Size = UDim2.new(0.25, 0, 1, 0)
toolButton.BackgroundColor3 = Color3.fromRGB(80, 80, 80)
toolButton.Text = tool.Name
toolButton.TextColor3 = Color3.new(1, 1, 1)
toolButton.Font = Enum.Font.SourceSans
toolButton.TextSize = 18
toolButton.Parent = row
toolButton.MouseButton1Click:Connect(function()
local character = player.Character
local backpack = player:FindFirstChild("Backpack")
if not character or not backpack then return end
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
if not humanoid then return end
local equippedTool = character:FindFirstChildOfClass("Tool")
if equippedTool == tool then
-- Move tool back to backpack manually to force unequip
tool.Parent = backpack
else
-- Move tool to character and equip
tool.Parent = character
humanoid:EquipTool(tool)
end
end)
local attributes = {
"Accuracy",
"Power",
"Push"
}
for i, attrName in ipairs(attributes) do
local label = Instance.new("TextLabel")
label.Size = UDim2.new(0.25, 0, 1, 0)
label.Position = UDim2.new(i * 0.25, 0, 0, 0)
label.BackgroundTransparency = 1
label.Text = tostring(tool:GetAttribute(attrName) or "-")
label.TextColor3 = Color3.new(1, 1, 1)
label.Font = Enum.Font.SourceSans
label.TextSize = 16
label.Parent = row
end
end
-- Initialize backpack GUI
local function createCustomBackpackGui()
local backpack = player:WaitForChild("Backpack")
for _, item in ipairs(backpack:GetChildren()) do
if item:IsA("Tool") then
addToolToGui(item)
end
end
end
-- Run it
createCustomBackpackGui()