get_child_count() is returning zero even though children are present in remote

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

My levels are set up as an inherited scene with the Path2D being inherited from a main map scene the levels just tweaking mobs spawning etc.
When I set up my code to check for level completion it kept completing the level early. Somehow even though I can see using remote that there are children attached to the Path2D, get_child_count() is returning zero. get_children() is similiarilly empty.

onready var local_path := $Path2D
    
    #checks to see if there are any mobs attached to the path
    func _physics_process(_delta: float) -> void:
    	if local_path.get_child_count() <=0:
    		next_wave()
  
      #starts the timer for the next wave or finishes the level
    func next_wave()->void:
    	if wave_timer.is_stopped() and wave_number<= number_of_waves:
    		wave_timer.start()
    	elif wave_timer.is_stopped() and wave_number > number_of_waves:
#end_level()
    		print("number of children of path = " +String(local_path.get_child_count()))

Spawn code:

class_name Path_Spawner
extends Path2D

onready var map := get_parent()


func spawn(type:String)->void:
	var follow := PathFollow2D.new()
	add_child(follow)
	match type:
		"basic_enemy":
			var enemy:= preload("res://Enemies/Enemy.tscn").instance()
			enemy.connect("end_of_the_road", map, "failing")
			enemy.connect("dead", map, "add_cash")
			follow.add_child(enemy)

Notw I have got around it by calling it in a script attached to the Path2D node but cannot figure out why this doesn’t work