I have been trying for hours to solve this script problem, the ChildRemoved event won’t trigger but ChildAdded event trigger normally, I tried to use the separate ChildRemoved script and it works, but I would like to know why it is not working together with ChildAdded.
Here’s the script…
local CLASS = "Tool"
local C_ = "<BP_TOOL> "
---------------------------------
local function InvAdd(item,slot)
-- script
end
local function InvRem(item)
-- script
end
---------------------------------
P_BP.ChildRemoved:Connect(function(_r)
if _r:IsA(CLASS) then
print(C_.. _r.Name.. " is a tool and has been removed from the backpack")
if CHAR:FindFirstChild(_r.Name) then
print(C_.. _r.Name.." in use")
else
print(C_.. _r.Name.." removed from backpack")
InvRem(_r)
end
else
print(C_.. _r.Name.. " isn't a tool and has been removed from backpack")
end
end)
P_BP.ChildAdded:Connect(function(_a)
if _a:IsA(CLASS) then
print(C_.. _a.Name.. " is a tool and has been added to the backpack")
local Find = false
for i,v in pairs(ToolSlots) do
if v.Info.TL_Tool.Text == "" then
if not Find then
Find = true
InvAdd(_a,i)
end
end
end
else
print(C_.. _a.Name.. " isn't a tool but has been added backpack")
end
end)
Thanks for any help!