Detecting Tool Deletion

Is there a possible way to detect if a tool gets deleted using a script that is inside a tool? I tried Tool.Destroying, PropertyChangedSignals, etc… I know that this is possible using a script outside the tool. However, I am not sure if this is possible inside the tool since scripts stop running nearly instantly when they get parented to nil (deleted). I was wondering if there was a hacky workaround to this.

2 Likes

Are you working with a server script? if so you might be able to use the Tool.Destroying in the same tool script, and the first line after that do script.Parent = game.ServerScriptService or some other container that allows your script to run. because if I do remember correctly, Tool.Destroying is fired before the tool is destroyed, and its just an idea.

2 Likes

Nope, it didn’t work. Thank you for the idea though.

Here’s the code btw:

Tool:GetPropertyChangedSignal("Parent"):Connect(function()
	if not Tool.Parent then
		script.Parent = game.ServerScriptService
		print("worked")
	end
end)
1 Like

Have you actually used the .Destroying Event. In the Code sample you sent Your using :GetPropertyChangedSignal() and the reason why thats important is because the 2 are not the same. :GetPropertyChangedSignal() fires after the fact, meaning that its parented to nil, so the next lines never run, where .Destroying says in the roblox docs, that is fired right before being destroyed, and should still exist as long as nothing is yielding.

I have to ask thought because the code sample you sent does not use the Destroying event

2 Likes

First of all, you’re* :trollface: (Don’t take this personally)

I tried Destroying. Same outcome.

1 Like

Wait. I actually take that back… (I AM AN IDIOT BRO)

1 Like

Awesome. If you are having troubles of it not working, then you could also make a script in serverscriptservice, and just listen for the destroying event there, and get all the players tools.

1 Like

Guess what, I just realized that it actually works without all this. I just made a stupid mistake. :skull:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.