how to transfer data between scenes?

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

(Sorry for my English, I use Google translator)
I had a problem that the text from Lineedit is not transferred to the global script

extends Node2D

func _ready():
    Global.Player_Name = $LineEdit

func _on_Button_pressed():

Global script:

extends Node

var Player_Name = ''

Edit: posted as answer.

Adam_S | 2019-08-21 13:56

:bust_in_silhouette: Reply From: Schweini
:bust_in_silhouette: Reply From: Zylann

The “from another scene” search also yields a lot of results, this has been answered many times, in many ways and many situations Search results for From another scene - Godot Engine - Q&A

:bust_in_silhouette: Reply From: Adam_S

You only get the node not the text.


Global.Player_Name = $LineEdit

should look like this:

Global.Player_Name = $LineEdit.text
:bust_in_silhouette: Reply From: Kyle Guarco

I just wanna say, while we’re posting answers here:

If you ever need to persist an entire node between scenes, you can re-parent to the root viewport.

var child = get_child(0)