How to make item appear in a gui

In my game I want the stuff in my inventory to appear in different categories in my GUI.
How would I do that? (Without hardcoding it in for each part)

Inventory: unknown (1)

Gui:

Script I want the code in:

local Player = game.Players.LocalPlayer
local WorkshopGui = Player.PlayerGui:WaitForChild("WorkshopGui")
local WorkShopButtons = Player.PlayerGui:WaitForChild("WorkshopButtons")
local BottomMenu = Player.PlayerGui:WaitForChild("BottomMenu")
local Stat = Player.PlayerGui:WaitForChild("Stats")
local ButtonsFrame = Player.PlayerGui.WorkshopGui.Buttons
local ReturnCam = game.ReplicatedStorage.ReturnCam
local Bridge = game.ReplicatedStorage.Bridge

-- FRAME VARIABLES --
local MotherboardFrame = WorkshopGui.MotherboardFrame
local RamFrame = WorkshopGui.RamFrame
local CpuFrame = WorkshopGui.CpuFrame
local GpuFrame = WorkshopGui.GpuFrame
local CoolerFrame = WorkshopGui.CoolerFrame
local PowerSupplyFrame = WorkshopGui.PowerSupplyFrame
local StorageFrame = WorkshopGui.StorageFrame



-- BUTTON VARIABLES --
local MotherboardButton = ButtonsFrame.MotherboardButton
local CpuButton = ButtonsFrame.CpuButton
local RamButton = ButtonsFrame.RamButton
local StorageButton = ButtonsFrame.StorageButton
local GraphicsCardButton = ButtonsFrame.GraphicsCardButton
local CoolerButton = ButtonsFrame.CoolerButton
local PowerSupplyButton = ButtonsFrame.PowerSupplyButton
local Inventory = WorkShopButtons.Inventory
local Close = WorkShopButtons.Close
local Glass = game.Workspace.PCTEST.PC.Glass

-----------------------------------------------------------------------
Close.MouseButton1Click:Connect(function(player)
	Glass.Transparency = 0.75
	Bridge:FireServer(player)
	WorkshopGui.Enabled = false
end)

Inventory.MouseButton1Click:Connect(function()
	WorkshopGui.Enabled = not WorkshopGui.Enabled
	MotherboardFrame.Visible = true
	RamFrame.Visible = false
	CpuFrame.Visible = false
	GpuFrame.Visible = false
	CoolerFrame.Visible = false
	PowerSupplyFrame.Visible = false
	StorageFrame.Visible = false
end)

MotherboardButton.MouseButton1Click:Connect(function()
	MotherboardFrame.Visible = true
	RamFrame.Visible = false
	CpuFrame.Visible = false
	GpuFrame.Visible = false
	CoolerFrame.Visible = false
	PowerSupplyFrame.Visible = false
	StorageFrame.Visible = false
end)


CpuButton.MouseButton1Click:Connect(function()
	CpuFrame.Visible = true
	MotherboardFrame.Visible = false
	RamFrame.Visible = false
	GpuFrame.Visible = false
	CoolerFrame.Visible = false
	PowerSupplyFrame.Visible = false
	StorageFrame.Visible = false
end)

RamButton.MouseButton1Click:Connect(function()
	RamFrame.Visible = true
	CpuFrame.Visible = false
	MotherboardFrame.Visible = false
	GpuFrame.Visible = false
	CoolerFrame.Visible = false
	PowerSupplyFrame.Visible = false
	StorageFrame.Visible = false
end)

StorageButton.MouseButton1Click:Connect(function()
	StorageFrame.Visible = true
	RamFrame.Visible = false
	CpuFrame.Visible = false
	MotherboardFrame.Visible = false
	GpuFrame.Visible = false
	CoolerFrame.Visible = false
	PowerSupplyFrame.Visible = false

end)

GraphicsCardButton.MouseButton1Click:Connect(function()
	GpuFrame.Visible = true
	StorageFrame.Visible = false
	RamFrame.Visible = false
	CpuFrame.Visible = false
	MotherboardFrame.Visible = false
	CoolerFrame.Visible = false
	PowerSupplyFrame.Visible = false

end)

CoolerButton.MouseButton1Click:Connect(function()
	CoolerFrame.Visible = true
	GpuFrame.Visible = false
	StorageFrame.Visible = false
	RamFrame.Visible = false
	CpuFrame.Visible = false
	MotherboardFrame.Visible = false
	PowerSupplyFrame.Visible = false

end)


PowerSupplyButton.MouseButton1Click:Connect(function()
	PowerSupplyFrame.Visible = true
	CoolerFrame.Visible = false
	GpuFrame.Visible = false
	StorageFrame.Visible = false
	RamFrame.Visible = false
	CpuFrame.Visible = false
	MotherboardFrame.Visible = false

end)
1 Like