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():
    print(Global.Player_Name)

Global script:

extends Node

var Player_Name = ''
in Engine by (60 points)

Edit: posted as answer.

4 Answers

+1 vote
Best answer

You only get the node not the text.

This:

Global.Player_Name = $LineEdit

should look like this:

Global.Player_Name = $LineEdit.text
by (1,433 points)
selected by
+1 vote
by (232 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

by (27,902 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)

get_viewport().add_child(child)
remove_child(child)
by (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.
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 webmaster@godotengine.org with your username.