Help needed in reparenting

Godot Version

extends Control

var CountryName = “”

func _ready():
CountryName = $LineEdit.text
$CountryText.text = CountryName

func _on_line_edit_text_submitted(new_event):
$Infotext1.visible = false
$LineEdit.visible = false
CountryName = $LineEdit.text
$CountryText.text = CountryName


im trying to change countrytexts parent to another scene(FlagCreator) but i dont know how


This line will remove the current scene and load flag_creator.tscn. If you are trying to keep data between scene changes look into Autoloads.


i understand it a little bitt but can you show me how tto code it?

Seems like the data you want to keep between scenes is “CountryName” so we’ll create a new script with that variable.

extends Node

var country_name: String

Add this script to Autoload as described in the documentation, and make sure we have “global variable” ticked on. I will assume it’s called GameData.

Your script will now set GameData.country_name = new_event and change scene to the flag creator. Inside the flag creator will be a script to set a label with that global data.

# flag creator
extends Control

func _ready() -> void:
    $CountryName.text = GameData.country_name