The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

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: https://pastebin.com/eUgBrA15
how it looks: https://imgur.com/gallery/Pecy0Ab

and here's the code of the player: https://pastebin.com/qXRcfzr2

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
Godot version 3.3.2
in Engine by (24 points)

1 Answer

0 votes
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")
by (6,942 points)

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.