How can I get the correct gui button after making new ones?

Hello, Devforum I made a system in which you can pickup items then it will add it to your inventory how can I detect the correct button being clicked? For example lets say I pick up an item and then I pick up another how can I get the item before the last one picked up?

Please attach more details to your question, for ex. some code, pictures, more explanation since the current question isn’t really clear. Also tell us what you have already tried.

What im attempting to do is instance a new gui button inside of a gui every time the player pressed the e key.
so;

local function newButton(actionName, inputState)
   if inputState == Enum.UserInputState.Begin then
      local new = instance.new("ImageButton", screenGui)
      new.Name = "newButton"
   end
end

contextActionService:BindAction("ADD_BUTTON", newButton, false, Enum.KeyCode.E)

now if I create two buttons so I press e twice how can I reference or differentiate between the image buttons if they were clicked. Because new will be overwritten with a new instance everytime so I wanna reference when the first image button created gets clicked. Does that kinda help you?