Getting an error when hiding a Node2d by TouchScreenButton

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

I am trying to close a Node2d based dialog by hiding it via touch screen button (which is a child of this dialog via another Node2d). I use the following code:

func _on_SettingsOK_released():
if GlobalScript.playEffects:
$SettingsOKButtonSound.stream = positiveSound
$SettingsOKButtonSound.play()
settingsOKButtonLight.enabled = false
settingsOKButtonLightBlob.visible = false
var settingsDialog = get_tree().get_nodes_in_group(“SettingsDialog”)[0]
if (settingsDialog.visible == true):
settingsDialog.visible = false

when this code is executed I get 4 error messages of the same kind:
E 0:00:40.730 _input: Condition “!is_visible_in_tree()” is true.
<C+±Quellcode>scene/2d/touch_screen_button.cpp:201 @ _input()

Code still works but i would like to get rid of the annoying messages.
Is there any solution?