• Godot Help
  • question about scene instance and signals

i have spawner, that periodically instanciates npcs. When they die they emit a signal.
i want to count how many enemies died. So i made node "gameStatsManager", preloaded packedScene of enemy and i try to connect signal "enemyDugDown" to function "printInfo", but when i start game it gives this error.

as i understood conect works with nodes that are already in the scene, instatiated. how can i specify signal connection to scenes that will be instatiated later in game?

The result of the preload() is a PackedScene. You need to instantiate it to have a node.

You're evidently using Godot 4, so you could do it like this:
@onready var enemyScene = preload("res://enemy.tscn").instantiate()

    DaveTheCoder thanks for reply. i might try it later, but i found other solution. i used autoload to create event bus. i created events.gd script where i create signals and then gameStatsManager connects to this event.
    enemy script

    gameStatsManager script

    events.gd