Make Icons Appear in Custom Inventory

Good afternoon, I have been trying to make a custom inventory system for my Roblox game, l4d style, at the moment I have managed to get a script which organizes the tools depending on their tooltip (Primary, Secondary, Item1, Item 2, Item 3)
What I am wanting to do now is for the icon of the tools that the player has in his inventory to be displayed in a gui, here I am attaching an image of how my GUI is organized,
imagen_2024-01-22_204535506
I don’t know how to start working on this so yes If someone could explain to me any way I could achieve my goal, I would greatly appreciate it :), here I leave my script, located in StarterGui, thank you very much.

task.wait(5)
local MaxHotbarItems = 5
local KeyBinds = {One = "Primary", Two = "Secondary", Three = "Item1", Four = "Item2", Five = "Item3"}

local UserInputService = game:GetService('UserInputService')
local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Backpack = Player.Backpack
local WeaponHandler = game:GetService("ReplicatedStorage"):FindFirstChild('WeaponHandler')

-----------Organizacion de el Gui
local StarterGui = game.StarterGui
local Gui = StarterGui:WaitForChild("CustomHotBarGui")
local Hotbar = Gui:WaitForChild("Hotbar")
local S = Hotbar:WaitForChild("Slots")

local Using

local Items = {
	["Primary"] = nil;
	["Secondary"] = nil;
	["Item1"] = nil;
	["Item2"] = nil;
	["Item3"] = nil;
}


local function WeaponEquip (Weapon)
	if Weapon.Parent ~= Character then
		Character.Humanoid:EquipTool(Weapon)
		print(Using)
	end
end

local function UnEquipTools ()
	Character.Humanoid:UnequipTools()
end

local function WeaponFunction (Tool)
	if Tool:IsA("Tool") then
		local ToolName = Tool.Name
		local ToolType = Tool.ToolTip
		Items[ToolType] = Tool
	end
end

local function updateRemove(tool)
	if not tool:IsA("Tool") then
		return
	end

	if tool.Parent == Character or tool.Parent == Backpack then
		return
	end

	if table.find(Items, tool) then
		local index = table.find(Items, tool)
		table.remove(Items, index)
	end
end

WeaponHandler.Event.OnClientEvent:Connect(function(Tool, Value)
	print(Tool)
end)

UserInputService.InputBegan:Connect(function(input,gameProcessed)
	if gameProcessed then
		return
	end
	if KeyBinds[input.KeyCode.Name] then
		local WeaponIndexSelected = KeyBinds[input.KeyCode.Name]
		Using = WeaponIndexSelected
		if Items[WeaponIndexSelected] then
			WeaponEquip(Items[WeaponIndexSelected])
		end
	end
end)

while true do
	local success, err = pcall(function()
		game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
	end)
	if success then
		break
	end
	task.wait()
	print("Pending Gui Disable")
end

for _, tool in pairs(Backpack:GetChildren()) do
	WeaponFunction(tool)
end

Backpack.ChildAdded:Connect(WeaponFunction)

Backpack.ChildRemoved:Connect(WeaponFunction)

Sorry if my Inglish is bad, I´m Mexican and my inglish is no the best.

1 Like

set the imagelabel’s image to tool’s texture like this

ImageLabel.Image = tool.TextureID

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.