Attempt to connect nonexistent signal

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

Hi, i have a Save/Load menu, when i load the player’s stats from file i want to emit a signal to the player script to update his stats. The problem is in title.

here’s the code of the save/load menu: extends CanvasLayerconst SAVE_DIR = "res://saves/"var save_path1 = SAVE_DI - Pastebin.com
how it looks: load - Album on Imgur

and here’s the code of the player: extends KinematicBody2Dexport var MAX_SPEED = 80export var acceleration - Pastebin.com

note: i have a autoloaded script

extends Node

var SceneSaver 
var PlayerPosition 
var player_position_loaded

var max_health_loaded
var health_loaded

func _process(_delta):
    SceneSaver = get_tree().current_scene.filename
:bust_in_silhouette: Reply From: Wakatta
onready var control = preload("res://SaveLoad/Control.gd")

In the above line Control is loaded as a resource or packedScene and what you need is an instance that has been added to the sceneTree

So in line 47 of your player script

control.connect("Health_Changed", self , "function")

You will get that error

You have several options

  • Use the nodepath of the Save/Load menu
  • Make the connection from the Save/Load menu instead using the player’s nodepath

Option 1

onready var control = get_tree().current_scene.get_node("SaveLodeMenu")

Option 2

func _ready():
    get_tree().paused = true
    set_current_selection(current_selection)
    check_state(save_path1, Text1Grup1)
    check_state(save_path2, Text1Grup2)
    check_state(save_path3, Text1Grup3)
    connect("Health_Changed", $PlayerNode , "function")

The player node is in another scene, how can i get that ?

ispilantebrusli | 2021-08-23 16:56