Hello
So i made this custom hot bar with this script and gui:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local Inventory = require(ReplicatedStorage.Module:WaitForChild("InventoryModule"))
local frame = script.Parent
local slotLabels = {}
for _, child in ipairs(frame:GetChildren()) do
if child:IsA("TextLabel") then
table.insert(slotLabels, child)
end
end
table.sort(slotLabels, function(a, b)
return a.LayoutOrder < b.LayoutOrder
end)
-- Update UI slots from inventory
local function updateHotbar()
for i, label in ipairs(slotLabels) do
local itemName = Inventory:GetSlot(i - 1) -- adjust for 0-based inventory
print("Slot", i - 1, "=", itemName)
if itemName then
label.Text = itemName
else
label.Text = "[Empty]"
end
end
end
-- Highlight the selected slot
local function highlightSlot(index)
for i, label in ipairs(slotLabels) do
if i == index then
label.BackgroundColor3 = Color3.fromRGB(255, 255, 0) -- selected color
else
label.BackgroundColor3 = Color3.fromRGB(139, 139, 139) -- default color
end
end
end
-- Map keycodes to slot numbers (adjusting to index order)
local keyToSlot = {
[Enum.KeyCode.One] = 5,
[Enum.KeyCode.Two] = 2,
[Enum.KeyCode.Three] = 3,
[Enum.KeyCode.Four] = 4,
[Enum.KeyCode.Five] = 1,
}
-- Handle key input
UIS.InputBegan:Connect(function(input, processed)
if processed then return end
local slotNumber = keyToSlot[input.KeyCode]
if slotNumber then
local selectedItem = Inventory:GetSlot(slotNumber - 1)
if selectedItem then
print("You selected:", selectedItem)
end
highlightSlot(slotNumber)
updateHotbar()
end
end)
-- Initial setup
updateHotbar()
highlightSlot(0)
And my current goal was the make a limiter(how many items you can carrie), remove the roblox tool system the default gui, make that the text labels dont just say empty that they say the actual tool ther holding and disable the meaning to deequip tool(i mean you can equipp , dropp it and use it but i dont wont that its placed in the backpack).
But i have 0 clue how to do all of this
NOTE:
I just ask for some tips or show were i can start doing somthing like this PLS dont write the scripts for me i just need tips i were and waht to do. i try as much as posible on my own to write the scripts exept i cant find the problems in my script.
i hope you all can help me with this complicated problem
Thank You