Argument 1 should be "Node" but is "Tween

Godot Version

4.2.2

Hi everyone,

it’s about this script:

extends Node2D

func _play_white_flash():
	visible = true

	get_node ("BackFlashWhite").play()

	var tween:Tween = Tween.new()
	add_child(tween)
	tween.interpolate_property(self, "modulate", ...

Everything worked fine in Godot 3.5.3, but switching to 4.2.2 an error at exporting my project occurs:
Invalid argument for "add_child()" function: argument 1 should be "Node" but is "Tween.

How could this be fixed?

EDIT:
I added a $: add_child($tween) and this seems to do the trick…

you dont have to add tween to the scene tree anymore. Instead you do the following:

var tween: Tween = get_tree().create_tween()

This is the way to do tweens in godot4. They are automatically in the scene-tree

1 Like

Thanks for the info!

It appears that my $-approach still works as well, but I’ll certainly switch to the “correct” way from now on.

1 Like