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

**URL:** <https://forum.defold.com/t/is-there-a-way-to-check-if-a-gui-node-has-been-deleted/70553>\
**Category:** Questions\
**Created:** [March 16, 2022, 10:40pm UTC](https://forum.defold.com/t/is-there-a-way-to-check-if-a-gui-node-has-been-deleted/70553 "2022-03-16T22:40:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![greay](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/greay/32/24600_2.png) [@greay](https://forum.defold.com/u/greay)\
**Post date:** [March 16, 2022, 10:40pm UTC](https://forum.defold.com/t/is-there-a-way-to-check-if-a-gui-node-has-been-deleted/70553/1 "2022-03-16T22:40:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [March 16, 2022, 10:52pm UTC](https://forum.defold.com/t/is-there-a-way-to-check-if-a-gui-node-has-been-deleted/70553/2 "2022-03-16T22:52:52Z")

</div>

> [@greay](#):
>
> since the nodes are created with gui.clone\_tree, I don’t have a node ID

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

> [@greay](#):
>
> I’d like to know if there’s a way to test whether it’s still alive first.

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:

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

```
