Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how to actually detect if a tool is removed?

when you equip a tool, the tool gets parented to the player's character. so i can't use ChildRemoved event on the backpack because it also fires the function when the tool is equipped.

i have tried checking if the tool is parented into the player's character when the childremoved event is fired then disconnecting the function after that. doesn't work

is there any way?

1 answer

Try using the AncestryChanged event

local Backpack = game:GetService("Players").LocalPlayer:WaitForChild("Backpack")
local Tool = Backpack:WaitForChild("Tool")

Tool.AncestryChanged:Connect(function(Tool, Parent)
	if not Parent then
		print("Tool is being removed!")
	end
end)

3 comments

0

I don't think they want this. They want to detect whether the tool is actually REMOVED and not equipped (because when equipping a tool it's moved to the player.Character).

0

nono, i mean when the tool is removed not equiped nor unequipped

0

Did you mean that you want to know if the tool is in the inventory or not?

This discussion is preserved as it was. New answers, comments, and votes are closed.