I have been struggling with this error for a good time now. I created a rat spawner very similar to the one we used in Alien Attack, the rats spawn and are visible when I add them as a child in the Rat Spawner scene. However, now I am updating score based on rat's death I need to use a signal. However when I connect them using this signal, the rats are invisible but I know they're there because I can see them spawning in the remote tab.
Here is my relevant code for the rat spawner
signal enemy_spawned(enemy_instance)
var enemy_scene = preload("res://scenes/rats.tscn")
@onready var spawn_positions = $RatSpawnPositions
func _on_timer_timeout():
spawn_enemy()
func spawn_enemy():
var spawn_positions_arrays = spawn_positions.get_children()
var random_spawn_position = spawn_positions_arrays.pick_random()
var enemy_instance = enemy_scene.instantiate()
#add_child(enemy_instance)
enemy_instance.global_position = random_spawn_position.global_position
emit_signal("enemy_spawned",enemy_instance)
And here is what I'm doing with it in the game scene
green-connected-arrow
func _on_rat_spawner_enemy_spawned(enemy_instance):
add_child(enemy_instance)