How to get varibale from other scene, BUT this variable changes in function

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

Hello, I have a question!
I have two scenes - CharacterCreation.tscn and Game.tscn
In CharacterCreation.tscn I have a LineEdit for input nickname, there is it’s code:

extends LineEdit

var Name = “PLAYER”

func _ready() → void:
connect(“text_entered”, self, “_on_text_entered”)

func _on_NameInput_text_entered(new_text):
Name = new_text

I send this script in autoloading and name it - PlayerNameNODE

In Game.tscn I have a label and there must be player name:

func _ready():
print("Your name is - ", PlayerNameNODE.Name)

But when I’m trying to get varibale from script it takes name from this string

var Name = “PLAYER”

So the name always is “PLAYER”, no matter what actual player input.

:bust_in_silhouette: Reply From: klaas

first thing that caught my eye

connect("textentered", self, "ontextentered")

func onNameInputtextentered(newtext):

the function name in connect does not match the functions name. This should throw a warning in the debug console.