As the title says, what can make a connection disconnect. All I know is by using connection:Disconnect(), and when a script with that connection gets :Destroy()
Also is this going to disconnect the connection?
local connections = {}
connections[1] = SomeInstance.SomeEvent:Connect(SomeFunction)
connections = nil
The script exists, and the connection as well, it’s just stored in nil.
Edit: whoops I was talking about this one below and how the connection is running but stored in nil. Anyways seems like @Lielmaster is able to test it yourself so it should be fine.
:Destroy() is not just setting the parent property to nil, it sets the parent of the object to nil, locks the parent property, and if it is a script, it disconnects all connections in that script, though the thread is still running. Test this code
workspace.ChildAdded:Connect(function()
print("ChildAdded")
end)
task.delay(5, function()
print("Destroying script in 5 seconds")
task.wait(5)
script:Destroy()
end)
while true do
task.wait(1)
local part = Instance.new("Part",workspace)
task.wait(1)
part:Destroy()
end
It will still insert parts but it wont print anymore