Is there a way to check if a GUI node has been deleted?

since the nodes are created with gui.clone_tree, I don’t have a node ID, but I do have a reference to the node itself. But interacting with it in any way (like checking if it’s equal to another node) triggers an error, so I’d like to know if there’s a way to test whether it’s still alive first.

Note that you can assign/change id of a node using gui.set_id().

We do not really provide any functions for these kinds of things. Our reasoning is usually that developers should know or should be able to keep track of the nodes or objects in the game. With that said I’m pretty sure you can use pcall to detect this:

local function is_node_alive(node)
    local ok, err = pcall(gui.get_position, node)
    return ok
end
3 Likes