Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Does ClearAllChildren() Disconnect RBXScriptSignals?

I'm making a GUI that lists all of the items in a table of strings.

Each item in the table is represented by a TextBox with a TextButton inside of it.

Whenever an item's TextButtonis clicked, the item is removed from the list, which is then repopulated. The button's event listener is then disconnected.

Repopulating the list entails destroying all of the TextBoxes with ClearAllChildren(), and then creating the list anew.

ROBLOX Wiki states, > "A connection is automatically disconnected if: ...The object the Event relates to is destroyed with the Destroy method."

It does not, however, mention the ClearAllChildren()method, which could be problematic, considering that the objects that the event listener relates to are destroyed that way.

What I want to know is: Is an RBXScriptSignaldisconnected if its respective object is destroyed by ClearAllChildren()?

1 comment

0

To clarify, whenever an item is removed from the list, the REST of the TextBoxes are removed using ClearAllChildren(), and I'm concerned that the event listeners connected to the TextButtons inside them won't be disconnected, since Destroy() was not used.

2 answers

✓ Accepted answer

The ClearAllChildren function uses the deprecated remove function. And, as you may know, the remove function simply sets the parent to nil; it does not disconnect connected events.

1 comment

0

I didnt even see this before adding my own answer >:L

This discussion is preserved as it was. New answers, comments, and votes are closed.