0 votes

(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 = ''
asked Aug 21, 2019 in Engine by Comet (60 points)

Edit: posted as answer.

4 Answers

+1 vote
Best answer

You only get the node not the text.


Global.Player_Name = $LineEdit

should look like this:

Global.Player_Name = $LineEdit.text
answered Aug 21, 2019 by Adam_S (981 points)
selected Aug 24, 2019 by Comet
+1 vote
answered Aug 21, 2019 by Schweini (234 points)
+1 vote

The "from another scene" search also yields a lot of results, this has been answered many times, in many ways and many situations https://godotengine.org/qa/search?q=From+another+scene

answered Aug 21, 2019 by Zylann (26,139 points)
0 votes

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)

answered Aug 22, 2019 by Kyle Guarco (66 points)
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 How to use this Q&A? before posting your first questions.