UnequipTools() is having a problem with Backpack:FindFirstChild()

I am making a Hotbar but this is the last step that I cannot get through. I want to identify a tool if it’s been destroyed when activating like when eating chocolate.

The problem here is when I use this UnequipTools()/ Put the tool inside backpack using UnequipTools() the character removed funtion identifies it as its been destroyed or not visible.

char.ChildRemoved:Connect(function(Tool)
	local ToolinBackpack = Backpack:FindFirstChild(Tool)
	if Tool:IsA("Tool") then
		if not ToolinBackpack then -- This thing Triggers When I UnequipTools() 
			print("Tool is not in backpack!")
		else
			print("Tool is in backpack!")
		end
	end
end)

What I’ve tried so far,

  • Useing WaitForChild() and FindFirstChild()

Nothing seems to work.

If it has been destroyed it can’t be activated or deactivated.

1 Like

Didnt quite get that tp be honest… Destroying a object doesnt trigger this?

Nevermind I misunderstood. Anyways, try like this:

if Tool:IsA("Tool") then
		if ToolinBackpack == nil then -- This thing Triggers When I UnequipTools() 
			print("Tool is not in backpack!")
		else
			print("Tool is in backpack!")
		end
	end
1 Like

Nope same issue… It triggers the print(“Tool is not in backpack!”)

Hold on, maybe I’m not understanding. What exactly are you trying to do here? If it has been destroyed obviously it won’t be detected in the backpack.

The thing is: FindFirstChild takes in a string, and returns an object with a matching name, in your code however, you passed in an object, Tool as the first argument. Idk why it didnt error, but yea, that might be your issue.

Try: Backpack:FindFirstChild(Tool.Name)

1 Like

Omg, Thanks a lot… It worked!

1 Like