Trying to assign value of type 'Node2D' to a variable of type [custom class].

Godot Version

4.2.1

Question

I keep getting an error as follows:
Trying to assign value of type 'Node2D' to a variable of type 'Source2D.gd'.

Where Source2D is a class that inherits from Node2D. The specific line is:

for source: Source2D in get_tree().get_nodes_in_group("Sources"):
		amplitude += source.wave_function(r, t)

Currently there is one node within the group and it is a Source2D node, so I assumed there was an issue with the script Source2D.gd that prevented it from running properly or smn, but I haven’t found any errors.

I found the issue: it was an issue with the script; I didn’t set placeholders in the _init function. Since I didn’t see any relevant results when I looked up the errors, I’m posting this anyway.

FYI the error that indicated it was the _init function:

Error constructing a GDScriptInstance.

Hope this helps.