ChildAdded/Removing not being called

I have a tool and I’m trying to detect when the player drops it, however every way I try to detect it none of them get called.

local UIS = game:GetService("UserInputService")

local tool = script.Parent

local config = require(tool:WaitForChild("Config"))

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

local mouse = player:GetMouse()

local ui = nil

local equipped = false
local debounce = false
local reloading = false

local ammo = 0
local spareAmmo = 0
ammo = config.maxAmmo
spareAmmo = config.defaultSpareAmmo

local holdAnim = config.holdAnim
local holdTrack = nil
if holdAnim ~= nil then
	holdTrack = char:WaitForChild("Humanoid"):LoadAnimation(holdAnim)
end

UIS.InputBegan:Connect(function(input, processed)
	if processed == true then return end
	
	if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch or input.KeyCode == Enum.KeyCode.ButtonR2 then
		Fire()
	end
	
	if input.KeyCode == Enum.KeyCode.R then
		if ammo < config.maxAmmo then
			Reload()
		end
	end
	
end)

function Fire()
	if equipped and not debounce and not reloading and ammo > 0 then
		debounce = true
		ammo -= 1
		
		local character = player.Character or player.CharacterAdded:Wait()
		
		tool:WaitForChild("Fire"):FireServer(mouse.Hit.p, character)
		
		ui:WaitForChild("Ammo").Text = ammo.."/"..spareAmmo
		
		task.wait(config.fireRate)
		debounce = false
	elseif ammo <= 0 then
		Reload()
	end
end

function Reload()
	if ammo < config.maxAmmo and equipped and not reloading and spareAmmo > 0 then
		reloading = true
		local toAdd = config.maxAmmo - ammo
		if spareAmmo >= toAdd then
			spareAmmo -= toAdd
			config.ReloadSound:Play()
			task.wait(config.reloadTime)
			ammo = config.maxAmmo
			ui:WaitForChild("Ammo").Text = ammo.."/"..spareAmmo
			reloading = false
		else
			spareAmmo = 0
			task.wait(config.reloadTime)
			ammo += spareAmmo
			ui:WaitForChild("Ammo").Text = ammo.."/"..spareAmmo
			reloading = false
		end
	end
end

tool.Equipped:Connect(function()
	equipped = true
	player = game.Players.LocalPlayer
	char = player.Character
	mouse = player:GetMouse()
	ui = tool:WaitForChild("GunUI") or player.PlayerGui:WaitForChild("GunUI")
	
	ui.Parent = player.PlayerGui
	ui:WaitForChild("GunName").Text = tool.Name
	ui:WaitForChild("Ammo").Text = ammo.."/"..spareAmmo
	
	if holdTrack ~= nil then
		holdTrack:Play()
	end
end)

tool.Unequipped:Connect(function()
	equipped = false
	
	ui.Parent = tool
	if holdTrack ~= nil then
		holdTrack:Stop()
	end
end)

workspace.ChildAdded:Connect(function(child)
	if child == tool then
		equipped = false
		ui.Parent = tool
		if holdTrack ~= nil then
			holdTrack:Stop()
		end
	end
end)

I’ve tried ChildAdded, ChildRemoving, DescendantAdded, tool:GetPropertyChangedSignal(“Parent”), on both the workspace and tool

Nothing gets called, I’ve looked at other posts similar and none worked.

What the heck. I tried turning off canDrop, then just using UIS to detect backspace then fire a remote event that puts it in workspace when triggered, and it still didnt work..

Hello,
I think maybe you could try to detect if tool is dropped with a character.
Because whenever player equip a tool it appears in their character (model). So I think that it would be better to detect it inside of it instead of the whole workspace.

Here’s example code I wrote:

local plr = game:GetService("Players").LocalPlayer;
local character = plr.Character or plr.CharacterAdded:Wait();
local backpack = plr:WaitForChild("Backpack");

character.ChildRemoved:Connect(function(child)
	
	if(not backpack:FindFirstChild(child.Name) and not character:FindFirstChild(child.Name))then
		print("player dropped "..tostring(child));
	else
		return;
	end
end)

Hope this helps.

I’ve already tried, however I could try detecting when it leaves your backpack and then ensuring its not just in your character.

Yes you can also try do that. If it will not work then you can try to do it from different file/LocalScript. My code works perfectly fine for me, try this code on empty baseplate. If described ealier methods will not work, then well I honestly don’t know what can be core of the problem.

P.S.
Ok my bad. I forgot that this script will detected every child, that was removed haha, like avatar items (hats, hair). You need also to check if child is a tool. Here’s fixed version:


local plr = game:GetService("Players").LocalPlayer;
local character = plr.Character or plr.CharacterAdded:Wait();
local backpack = plr:WaitForChild("Backpack");

character.ChildRemoved:Connect(function(child)
	
	if(not backpack:FindFirstChild(child.Name) and not character:FindFirstChild(child.Name) and child:IsA("Tool"))then
		print("player dropped "..tostring(child));
	else
		return;
	end
end)

Hope this message will help.