Code not working

Godot Version

extends Control

var CountryName = “”

var text = $LineEdit.text

func _ready():
pass

func _on_line_edit_text_submitted():
CountryName = text
$Label.text = str(CountryName)

Question

I got some of the code from forums and it should work but then when i try to start the project this error comes: Invalid get index ‘Text’ (on base: ‘null instance’).

Try changing the above to:

@onready var text = $LineEdit.text

ty it worked

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.