# creating a new tween and adding it as a child
var tween = Tween.new()
add_child(tween)
# it could be any other node
var node = ColorRect.new()
add_child(node)
# white is the default modulate color , also you can use self_modulate if the node has children
var final_col = Color.white
# this is the condition which make us decide to make the alpha equal 1 [show] or 0 [hide]
var appear = false
# if appear is true the final color alpha will be equal one else it will be equal zero
final_col.a = 1.0 if appear else 0.0
# adding the required params to the tween
tween.interpolate_property(node, 'modulate', node.modulate, final_col, 2, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
# starting the tween
tween.start()
# wait until tween finishes
yield(tween, 'tween_all_completed')
# here you can check if appear == false and delete the node or the node.modulate.a == 0.0
if !appear:
# we remove the child but it will not be deleted
remove_child(node)
# we queue the node to be deleted in the next idle frame
node.queue_free()