Question with connections

If I assign a connection to q variable, for example

local connection = Event1:Connect(funcA)

and I repeat the assign once again, will it automatically disconnect the old one and assign the new one? Or it adds up another connection and the old connection is handled without being stored in the variable?

Same thing here, if I do connection = nil but not connectuon:Disconnect() what happens to the connection?

1 Like

then you would have a memory leak since you did not clean it up properly, you need to do :Disconnect

2 Likes

Ok, but what about the first question?

No, it wont Disconnect the previous one, you should manually Disconnect() that previous Connection, as Artzified said, that will cause a memory leak too

for this one, still no; you need to manually disconnect them, you can use a module (usually called a Maid module) to handle your connections

1 Like

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