Inventory
Key RequiredUniversal

Inventory

Universal ScriptAkage_JPNAkage_JPN 510 views 28 executesUpdated Jan 10, 2026
5.0/ 5(1 votes)
10100% Positive
Lua Script•252 lines (7117 chars)
--====================================================
-- Unified Item Slot System (Stable Final)
--====================================================

--========== Services ==========
local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")
local UIS = game:GetService("UserInputService")

local player = Players.LocalPlayer

--========== Disable default hotbar ==========
pcall(function()
	StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
end)

--========== State ==========
local MAX_SLOTS = 10
local SlotLimit = 4
local slots = {}
local EquippedSlot = nil
local KeepEquip = false
local SlotType = "Normal" -- Normal / Ghost
local LastEquippedTool = nil

--========== GUI root ==========
local gui = Instance.new("ScreenGui")
gui.Name = "UnifiedItemSlotGui"
gui.ResetOnSpawn = false
gui.Parent = player:WaitForChild("PlayerGui")

--========== Toggle line button ==========
local toggleBtn = Instance.new("TextButton", gui)
toggleBtn.Size = UDim2.fromScale(0.2, 0.015)
toggleBtn.Position = UDim2.fromScale(0.4, 0.85)
toggleBtn.Text = ""
toggleBtn.BackgroundColor3 = Color3.fromRGB(120,120,120)
toggleBtn.BackgroundTransparency = 0.4
Instance.new("UICorner", toggleBtn)

--========== Main panel ==========
local panel = Instance.new("Frame", gui)
panel.Size = UDim2.fromScale(0.7, 0.35)
panel.Position = UDim2.fromScale(0.15, 0.48)
panel.BackgroundColor3 = Color3.fromRGB(30,30,30)
panel.BackgroundTransparency = 0.1
panel.Visible = false
Instance.new("UICorner", panel)

toggleBtn.MouseButton1Click:Connect(function()
	panel.Visible = not panel.Visible
end)

--========== Layout ==========
local layout = Instance.new("UIListLayout", panel)
layout.Padding = UDim.new(0.02,0)

--========== Title ==========
local title = Instance.new("TextLabel", panel)
title.Size = UDim2.fromScale(1, 0.12)
title.Text = "Slot Edit"
title.TextScaled = true
title.BackgroundTransparency = 1
title.TextColor3 = Color3.new(1,1,1)

--========== Slot limit ==========
local limitRow = Instance.new("Frame", panel)
limitRow.Size = UDim2.fromScale(1, 0.1)
limitRow.BackgroundTransparency = 1

local limitLabel = Instance.new("TextLabel", limitRow)
limitLabel.Size = UDim2.fromScale(0.4,1)
limitLabel.Text = "Slot limit"
limitLabel.TextScaled = true
limitLabel.BackgroundTransparency = 1
limitLabel.TextXAlignment = Enum.TextXAlignment.Left
limitLabel.TextColor3 = Color3.new(1,1,1)

local limitBox = Instance.new("TextBox", limitRow)
limitBox.Size = UDim2.fromScale(0.2,1)
limitBox.Position = UDim2.fromScale(0.45,0)
limitBox.Text = tostring(SlotLimit)
limitBox.TextScaled = true
limitBox.BackgroundColor3 = Color3.fromRGB(60,60,60)
limitBox.TextColor3 = Color3.new(1,1,1)
Instance.new("UICorner", limitBox)

local reflectBtn = Instance.new("TextButton", limitRow)
reflectBtn.Size = UDim2.fromScale(0.25,1)
reflectBtn.Position = UDim2.fromScale(0.7,0)
reflectBtn.Text = "Reflect"
reflectBtn.TextScaled = true
reflectBtn.BackgroundColor3 = Color3.fromRGB(60,120,60)
reflectBtn.TextColor3 = Color3.new(1,1,1)
Instance.new("UICorner", reflectBtn)

--========== Slot type ==========
local typeRow = Instance.new("Frame", panel)
typeRow.Size = UDim2.fromScale(1,0.1)
typeRow.BackgroundTransparency = 1

local typeLabel = Instance.new("TextLabel", typeRow)
typeLabel.Size = UDim2.fromScale(0.4,1)
typeLabel.Text = "Slot type"
typeLabel.TextScaled = true
typeLabel.BackgroundTransparency = 1
typeLabel.TextXAlignment = Enum.TextXAlignment.Left
typeLabel.TextColor3 = Color3.new(1,1,1)

local typeBtn = Instance.new("TextButton", typeRow)
typeBtn.Size = UDim2.fromScale(0.4,1)
typeBtn.Position = UDim2.fromScale(0.5,0)
typeBtn.Text = "[Normal]"
typeBtn.TextScaled = true
typeBtn.BackgroundColor3 = Color3.fromRGB(80,80,80)
typeBtn.TextColor3 = Color3.new(1,1,1)
Instance.new("UICorner", typeBtn)

typeBtn.MouseButton1Click:Connect(function()
	SlotType = (SlotType == "Normal") and "Ghost" or "Normal"
	typeBtn.Text = "["..SlotType.."]"
	updateSlots()
end)

--========== Keep Equip ==========
local keepRow = Instance.new("Frame", panel)
keepRow.Size = UDim2.fromScale(1,0.1)
keepRow.BackgroundTransparency = 1

local keepLabel = Instance.new("TextLabel", keepRow)
keepLabel.Size = UDim2.fromScale(0.5,1)
keepLabel.Text = "Keep Equip"
keepLabel.TextScaled = true
keepLabel.BackgroundTransparency = 1
keepLabel.TextXAlignment = Enum.TextXAlignment.Left
keepLabel.TextColor3 = Color3.new(1,1,1)

local keepBtn = Instance.new("TextButton", keepRow)
keepBtn.Size = UDim2.fromScale(0.3,1)
keepBtn.Position = UDim2.fromScale(0.6,0)
keepBtn.Text = "OFF"
keepBtn.TextScaled = true
keepBtn.BackgroundColor3 = Color3.fromRGB(80,80,80)
keepBtn.TextColor3 = Color3.new(1,1,1)
Instance.new("UICorner", keepBtn)

keepBtn.MouseButton1Click:Connect(function()
	KeepEquip = not KeepEquip
	keepBtn.Text = KeepEquip and "ON" or "OFF"
	keepBtn.BackgroundColor3 = KeepEquip and Color3.fromRGB(60,120,60) or Color3.fromRGB(80,80,80)
	LastEquippedTool = nil
end)

--========== Slot bar ==========
local slotBar = Instance.new("Frame", gui)
slotBar.Size = UDim2.fromScale(0.9,0.1)
slotBar.Position = UDim2.fromScale(0.05,0.88)
slotBar.BackgroundTransparency = 1

local barLayout = Instance.new("UIListLayout", slotBar)
barLayout.FillDirection = Enum.FillDirection.Horizontal
barLayout.Padding = UDim.new(0.015,0)

--========== Core logic ==========
function equipSlot(i)
	local tool = slots[i]
	if not tool then return end

	if EquippedSlot == i then
		if tool.Parent == player.Character then
			tool.Parent = player.Backpack
		end
		EquippedSlot = nil
		return
	end

	if player.Character then
		for _,t in ipairs(player.Character:GetChildren()) do
			if t:IsA("Tool") then
				t.Parent = player.Backpack
			end
		end
	end

	tool.Parent = player.Character
	EquippedSlot = i
end

function rebuildSlots()
	slots = {}
	local backpack = player.Backpack
	if not backpack then return end

	for _,tool in ipairs(backpack:GetChildren()) do
		if tool:IsA("Tool") then
			table.insert(slots, tool)
		end
	end
end

function updateSlots()
	for _,c in ipairs(slotBar:GetChildren()) do
		if c:IsA("TextButton") then c:Destroy() end
	end

	for i = 1, math.min(SlotLimit, #slots) do
		local tool = slots[i]
		local btn = Instance.new("TextButton", slotBar)
		btn.Size = UDim2.fromScale(0.09,1)
		btn.Text = tool.Name
		btn.TextScaled = true
		btn.BackgroundColor3 = Color3.fromRGB(40,40,40)
		btn.TextColor3 = Color3.new(1,1,1)
		Instance.new("UICorner", btn)

		btn.MouseButton1Click:Connect(function()
			equipSlot(i)
		end)
	end
end

--========== Events ==========
reflectBtn.MouseButton1Click:Connect(function()
	local n = tonumber(limitBox.Text)
	if n then
		SlotLimit = math.clamp(math.floor(n),1,MAX_SLOTS)
		limitBox.Text = tostring(SlotLimit)
		updateSlots()
	end
end)

player.Backpack.ChildAdded:Connect(function()
	rebuildSlots()
	updateSlots()
end)

player.Backpack.ChildRemoved:Connect(function()
	rebuildSlots()
	updateSlots()
end)

player.CharacterAdded:Connect(function()
	task.wait(0.2)
	rebuildSlots()
	updateSlots()
	LastEquippedTool = nil
end)

--========== Init ==========
task.wait(0.5)
rebuildSlots()
updateSlots()

Features & Information

For friend

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts