How might one go about minimizing the number of "errors" given by calling 'if get_node(item):'?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gamersen

As shown in the photo, line 15 checks to see if the node “item” exists. But since it doesn’t, the engine throws out dozens of errors a second. Is there a way I can minimize those errors or remove them all together while still having the code check if the node exists?

:bust_in_silhouette: Reply From: jgodfrey

You probably want to check for the existence of the node via has_node() before accessing it. So, something like this:

if has_node("Item"):
    var item_node = get_node("Item")
    # do something with item_node