Hello, I want to know why this issue is happening because when I drop a item it drops it but if there were items before that got dropped then they will be dropped as well.
code:
for i,itemValue in pairs (Inventory:GetChildren()) do
itemValue.Changed:Connect(function()
print("ItemValue changed")
local itemGui = InventoryGui.ItemList:FindFirstChild(itemValue.Name)
if itemGui then
itemGui.ItemAmount.Text = itemValue.Value
if itemValue.Value <= 0 then
itemGui.Visible = false
else
itemGui.Visible = true
end
end
end)
end
for i, ImgButton in pairs(InventoryGui:WaitForChild("ItemList"):GetDescendants()) do
if (ImgButton.ClassName == "ImageButton") then
ImgButton.MouseButton2Up:Connect(function()
local mouseLocation = UserInputService:GetMouseLocation()
gui.Position = UDim2.new(0, mouseLocation.X, 0, mouseLocation.Y)
gui.Visible = true
local itemFrame = ImgButton.Parent
local itemValue = Inventory:FindFirstChild(itemFrame.Name)
local itemVal = Inventory:FindFirstChild(itemFrame)
gui.Info.Visible = false
local droppable = itemValue:WaitForChild("Drop")
print("Drop")
if droppable.Value == true then
gui.Info.Visible = false
print("Drop = true")
gui.Drop.MouseButton1Click:Connect(function()
print(itemValue)
if itemValue.Value > 0 then
local DropItem = DropItem:InvokeServer(itemFrame.Name)
if DropItem == true then
if itemValue.Value > 0 then
itemFrame.ItemAmount.Text = Inventory:WaitForChild(itemFrame.Name).Value
end
end
end
end)
else
if droppable.Value == false then
gui.Info.Visible = true
end
end
end)
end
end