Ensuring correct clean up

Say I have a class called “Tool”

and then I have another called “Sword” which inherits from “Tool”.

But lets say I want to destroy the sword, how do I properly cleanup?

Do I have to make sure I destroy/set to nil/disconnect everything in the sword first, before then doing the same for tool?

And if say I have my sword, and destroy it, how can I make sure that it goes back and also destroys the instance of Tool it made as well?

local mySword = Sword.new()

mySword:Destroy()
-- doesn't tool exist?
```

I’m assuming Sword.new() is using metatables? If so, add another key called “Instance” into the table and have it equal the instance. You can then do

local mySword = Sword.new()

mySword.Instance:Destroy()
mySword = nil