[SOLVED] How do you manage dynamically created GUI nodes when using on_reload?

I currently have a GUI script that has an on_reload call. The GUI dynamically creates text nodes and stores them in a table, so whenever I reload the game I want to clear references to the old nodes and update the table.

This works fine when reloading a script. I can iterate over the table, delete each node and set each table value to nil. But if I reload that GUI component that has the text nodes in it, those text nodes are deleted and recreated automatically, so when I iterate over the table I get a “deleted node” error, since I’m trying to delete a node that was already deleted.

It seems like I need a solution that either checks for a deleted node before deleting it, or checking if the GUI component specifically was reloaded. Is there a way to do either of these things, and if not, how do you solve this?

Try using pcall?

2 Likes

Completely forgot about pcall… I just wrapped pcall around gui.delete_node in my loop and it worked perfectly. Thanks!

1 Like