can anyone help for a little script i made for my inventory GUI im trying to make? this is a button to unequip a weapon/armor (the part to remove the weapon/armor isnt made yet but it shouldn't be a problem), the problem is that i want it to be in the first empty slot of the inventory but it goes in all of them :/
function OnClicked() local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent local item = script.Parent.Parent.Parent.ItemName.Value if item ~= "None" then local d = player.PlayerGui.UI.Inventory:getChildren() for i=1, #d do if d[i].ItemName.Value == "None" then d[i].ItemName.Value = item end end player.PlayerGui.Items:findFirstChild(item):remove() script.Parent.Parent.Visible = false script.Parent.Parent.Parent.Visible = false script.Parent.Parent.Parent.ItemName.Value = "None" end end script.Parent.MouseButton1Click:connect(OnClicked)