Instance:DisconnectAllConnections()

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.)

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

13 Likes

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

I second this.

1 Like

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().

12 Likes

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

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.

2 Likes

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