Hello again, DevForums! I recently asked the question about how to make an inventory system, but didn’t get any good solutions to my question, most likely due to it being an extremely broad question. This time, I am asking about how I would add an item to an inventory system. My plan is for players to able to click an item to add it into their inventory which would take up any one of the slots:

My issue with this however is that I don’t know how to add an item into one of the slots inside the inventory gui when a player clicks on an item. I thought about using int values to determine what item is in a slot, but it didn’t answer my question to how I would be able to even get an item into a slot.
Just have a table. Whenever a player clicks to add an item get the item name from the Gui they clicked on, and add that as a string to the table. Also update the inventory Gui to showcase their selection.
local inventory = {}
local inventoryframe = --reference to inventory frame
local clickableitems = --reference to frame with all the Gui buttons:GetChildren()
for i,v in pairs (clickableitems) do
v.Activated:Connect(function ()
if inventory[v.Name] then
inventory [v.Name] += 1
Inventoryframe[v.Name].AmountLabel.Text = inventory[v.Name]
else
inventory[v.Name] = 1
local frame = instance.new("Frame")
frame.Name = v.Name
local amountlabel = instance.new("TextLabel")
amountlabel.Name = "AmountLabel"
amountlabel.Text = "1"
frame.Parent = inventoryframe
amountlabel.Parent = frame
--do more custization like images, item name labels etc.
end
end)
end
Thanks for your cooperation! With the help of your script, I used it and managed to change it to add in parts that was clicked.