Sorry about the confusing title. I was not sure how to phrase it. Please bare with me, as I am a beginner at Roblox Lua.
I am trying to create a custom inventory, and am making some progress. I created an "Equipment" GUI that has multiple slots within. Each of these slots have string and numbervalues within, to give items a name and stack values.
I have a wooden sword on the ground. In the sword object, I made a GUI object, and a script that clones the gui object into the playergui when you click on the sword. The GUI object asks if you want to pick up the sword or not, with a script within for the yes/no buttons. If you click yes, it imports the items name into my custom inventory slots.
This part works wellish (Even if not the best way to do it). What I am struggling with now is: I want to click on this item in the custom inventory, and have a prompt that opens on what to do with the item, (Equip, Drop, Delete, etc). As far as my understanding goes, I would need to have a GUI element created for each individual item slot, with the options for equip, delete within each element. This seems rather clunky though. I dont want to have to create that many additional GUI objects, and especially as the inventory grows dynamically, it seems a hassle to have to script it to create a new inventory slot, new inventory slot values, AND a new GUI for that new slot, and clone in the scripts needed.
My main question is that. Is there a way I could have one generic GUI window with the selections for "Equip, Delete, Drop", that opens when you click on any item in my inventory window. But have the generic GUI window know which item you clicked on, so it knows which one to drop/equip?
I hope this makes some sense. Kind of a hard thing to get off my brain, onto "paper". Here are the scripts I am using:
Script within my Wooden Sword tool:
local c =nil
function onClick(click)
for i,v in pairs (script.Parent:GetChildren()) do
if v.ClassName == "ScreenGui" then
c = v:Clone()
c.Parent = click.PlayerGui
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClick)
Script within the GUI within my wooden sword that gets cloned to PlayerGUI:
local inv = script.Parent.Parent.Parent.Main.MenuButton.CharacterButton.EquipBox
local invparts = inv:GetChildren()
local plr = game.Players.LocalPlayer
function yes()
script.Parent.yesbutton.Image = "http://www.roblox.com/asset/?id=674373802"
wait(.4)
script.Parent.yesbutton.Image = "http://www.roblox.com/asset/?id=674373565"
wait(.3)
script.Parent.Parent:Destroy()
for i, v in pairs(invparts) do
wait(0.5)
if v.SlotValue.Value == "" then
v.SlotValue.Value = "Wooden Sword"
v.Amount.Value = "1"
v.SlotLabel.Text = v.SlotValue.Value
v.SlotLabel.Visible = true
break
end
end
end
function no()
script.Parent.nobutton.Image = "http://www.roblox.com/asset/?id=674374266"
wait(.4)
script.Parent.nobutton.Image = "http://www.roblox.com/asset/?id=674374562"
wait(.3)
script.Parent.Parent:Destroy()
end
script.Parent.yesbutton.MouseButton1Click:connect(yes)
script.Parent.nobutton.MouseButton1Click:connect(no)
If you would like to see what I have so far, i have the place active. Just click on the back down arrow to open the menu GUI, and then click on the character, and the "Equipment" selection. Then pick up the wooden sword by clicking on it.
https://www.roblox.com/games/671061956/SBOtest
thank you!

3 comments
Wow. Thank you very much for the detailed response! I will not lie, 90% of that went right over my head. But I am a quick study, and using your post and other resources, I think I will get it after some practice. I am going to start practicing some ModuleScripts now. I think perhaps starting a custom inventory a couple days after being introduced to Roblox Lua was a bit of a large order, but a goo
Update: Easier than I thought! Using your examples, I was able to make a ModuleScript to store a couple different sword data. Then made a brick that when clicked on, opened a GUI displaying an items name from my modulescript table. Worked well! Thank you!
Glad you got it! Feel free to message me on Roblox if you want further explanations/clarifications (though my response time is ~1-2 days). (Also, be careful of the comment's maximum length on this site.)