Instance.Destroying Not Firing When Parent Is Being Destroyed

I have a tool which when equipped it will have a GUI pop up and once used, it will destroy the tool.

The issue that I have is that once I destroy the Tool from the server script, the client script that I have under the tool doesn’t have the Tool.Destroying event fire, which means the GUI will stay there forever. The weird thing is, I use this tool in one of my other games, and it prints just fine, but with using the tool on a plain baseplate, it does not fire (which might be because there is more stuff happening on the server on the other game, which leads to a delay in the tool actually being destroyed, allowing the event to be fired or something??)

Snippet of the local script code:

function onDestroying()
	print("destroying!!!")
	if currentFrisbeeChargeGUI ~= nil then
		currentFrisbeeChargeGUI:Destroy()
	end
end

Tool.Activated:Connect(onActivated)
Tool.Equipped:Connect(onEquipped)
Tool.Unequipped:Connect(onUnequipped)
Tool.Destroying:Connect(onDestroying)

I’ve done some research, but I cannot find a good fix for this, is there any other way to detect when the tool is being destroyed so that I can have the GUI be destroyed and not be there forever?

1 Like

Not sure if this is helpful but I think Destroying event only fires when called directly on the instance. Try AncestryChanged:Connect(function( child,parent) … ) and check if the parent is nil

I tried that too and it didn’t work.

Just unequip the tool before destroying and make the ui go away on the unequip event instead
I’m assuming it doesnt work because the local script is IN the tool being destroyed… so its destroyed too before the event is fired

1 Like

Can we revive this? This is super annoying.

2 Likes