Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how to actually detect if a tool is removed?

Asked by
noposts 75
7 years ago
Edited 7 years ago

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

Log in to vote
0
Answered by
Validark 1580 Snack Break Moderation Voter
7 years ago
Edited 7 years ago

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)
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). Thundermaker300 554 — 7y
0
nono, i mean when the tool is removed not equiped nor unequipped noposts 75 — 7y
0
Did you mean that you want to know if the tool is in the inventory or not? Bazuxk 95 — 7y
Ad

Answer this question