Enter your password

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

What node is used for text input?

The player should enter the key and click the button to confirm and the script will run:

var KEY = "CorrectKey"

func _on_Button_pressed():
    if KEY == "CorrectKey":
        get_tree().change_scene("res://CalledLevel")
    else:
        return
:bust_in_silhouette: Reply From: Eidam

Hello, for text input is used nodes LineEdit a TextEdit. In your situation probably more like use LineEdit.

Code will look something like this:
func _on_Button_pressed():
if $“LineEdit”.text == “Abcd”: (Eventual using get_node)
get_tree().change_scene(“res://CalledLavel”)
else:
return

I hope it will help you (:

func _on_Button_pressed():

    if $LineEdit.text == "password":
	    get_tree().change_scene("res://...")

Worked like a charm. Thanks!

Suleymanov | 2020-11-06 20:10

Of course! I forgot “.text” in my code, sorry.
Thanks, I repair it (:

I’m glad, I helped you.

Eidam | 2020-11-06 20:42