An instances connections are disconnected when that instance is destroyed but you’ll need to nil the connection’s table index otherwise the reference to that connection object will still exist (and won’t be garbage collected).
local button = script.Parent
local connections = {}
local mouseClickConnection
mouseClickConnection = button.MouseButton1Click:Connect(function()
print("Clicked!")
end)
table.insert(connections, mouseClickConnection)
button.AncestryChanged:Connect(function(child, parent)
if parent == nil then
connections[mouseClickConnection] = nil
end
end)
No it wont. The script will stop running when destroyed and the connections will no longer be active and should be garbage collected. You can test out the behavior by adding this script inside a part: