Instance:DisconnectAllConnections()

instance
#1

Self-explanatory. Say, a part has a touched event, and two scripts are working on that part. One script has called a connection event, but the other script wants to disconnect that event. (or disconnect all other events). So you can call Part:DisconnectAllConnections() (and disconnect all other connections associated with it).

(Keep in mind, that if you call Instance:DisconnectAllConnections() from the client, and the connection happened in the server in Experimental Mode off, and vise versa, then it won’t work. Wasn’t that already obvious?)

(Edit: Idea not plausible. Don’t count on it.)

#2

Sounds like a hack. You should just have your scripts communicate better.

11 Likes
#3

I would actually love to have this added.
It would allow me to remove 40 lines of code dedicated to managing remote event connections.

1 Like
#4

I second this.

#5

Internally we discussed adding a method like this but ultimately decided against it because it violates a lot of assumptions about how things work. For example, scripts would no longer be able to assume that the PlayerLeaving event will fire when a player leaves the game because another script might have called Player:DisconnectAllConnections().

8 Likes
#6

Would this possibly be implementable on RemoteEvents or BindableEvents? Or would the solution still be the same as mentioned above?

#7

I think this would still be useful in the form of disconnecting all RBXScriptSignals. If you disconnect connections made by the developer and not the ones made by core scripts and such, it would be useful without breaking standard dependencies.

1 Like