Line of code could not parse globe class from another gd file and another line of code is expected indented block after "if" block

Godot Version

4.1

Question

hi, im having trouble with a line of code, this is the code:

func _ready():
	(get_parent() as Ghost).direction_change.connect(on_direction_change)

(the (get_parent() as Ghost).direction_change.connect(on_direction_change) one is the one that has an error)

the error says “Could not parse global class “Ghost” from “res://SCENES/ghost.gd”.”, i have already putted a class_name for Ghost

theres also another error in the ghost.gd file in this line:

func scatter_position_reached():
	if current_scatter_index < 3:
		current_scatter_index += 1
	else:
		current_scatter_index = 0
	navigation_area_2d.target_position = movement_targets.scatter_targets[current_scatter_index].position

(the func scatter_position_reached(): one is the one that has the error)

the error in this one says “Expected indented block after “if” block.”

im a little confused on both of these errors, how do i fix these?

In order for the class_name to be recognized Godot has to be able to read the whole file. This syntax error makes it impossible for the parser to proceed.

It might actually be an error from a line above func scatter_position_reached():

Is there an if statement above it? could you check the indentation for that or add pass?

theres an “if” statement above func scatter_position_reached():, but its in another function and its incomplete, just realized this now lol, the tutorial im using gets to the if statement later on