i’m working on a inventory system and i was following BloxyHDD Video tutorial and i ran into an Error that is confusing
External Mediaif i drop 2 items and pick one of them, somehow the value glitches and gives me more then 1 and gives an error about the gui that i clicked and it clearly doesn’t have any connection between them
but if i drop 1 item and pick it up it works fine
Gui Script
local rep = game:GetService("ReplicatedStorage")
local Button = script.Parent
Button.MouseButton1Click:Connect(function()
rep.remotes.InventorySystem.DropItem:FireServer(Button.Name)
end)
Server Script
local CollectionService = game:GetService("CollectionService")
local SSS = game:GetService("ServerScriptService")
local rep = game:GetService("ReplicatedStorage")
local manager = require(SSS.PlayerData.Manager)
local itemManager = require(SSS.PlayerData.Manager.ItemModule)
local items = CollectionService:GetTagged("Item")
local remotes = rep.remotes
local PickUpCD = {}
local DropCD = {}
for i,item in workspace.DroppedItems:GetChildren() do
item.ProximityPrompt.Triggered:Connect(function(player)
if table.find(PickUpCD,player) then return end
table.insert(PickUpCD,player)
task.delay(5,function()
table.remove(PickUpCD,table.find(PickUpCD,player))
end)
print("triggered")
item.ProximityPrompt:Destroy()
for i,v in item:GetChildren() do
print(v)
end
itemManager.AddItem(player,item.Name, 1)
item:Destroy()
end)
end
workspace.DroppedItems.ChildAdded:Connect(function(child)
for i,item in workspace.DroppedItems:GetChildren() do
item.ProximityPrompt.Triggered:Connect(function(player)
local ItemName = item.Name
item:Destroy()
itemManager.AddItem(player,ItemName, 1)
end)
end
end)