Help for 14. LineEdit - Getting Text From the Player

for some reason I can’t use .clear in my code:

extends Control

func _ready():
** var prompts = [“tomer”, “coding”, “games”, “exited” ]**
** var story = “there was a man named %s, and he liked learning %s, his dreams where to make %s for a living, and while learning he felt %s for the future”**
** $VBoxContainer/DisplayText.text = story % prompts **


func _on_PlayerText_text_entered(new_text):
** $VBoxContainer/DisplayText.text = new_text**
$VBoxContainer/DisplayText.clear()

it always says Invalid call. Nonexistent function ‘clear’ in base ‘label’.

Hi there,

the reason you are getting this error is that DisplayText and PlayerText are two different things.

DisplayText is a Label node that doesnt have a .Clear() method. but PlayerText is a LineEdit node, that does have a .Clear() method.
where you have this

func _on_PlayerText_text_entered(new_text):
$VBoxContainer/DisplayText.text = new_text
$VBoxContainer/DisplayText.clear()

you need to change it to the following

func _on_PlayerText_text_entered(new_text):
$VBoxContainer/DisplayText.text = new_text
$VBoxContainer/PlayerText.clear()

and thus calling the Clear() method on the LineEdit.

best way to double check if there is the method you are looking for is there or not, is to right click the node in the scene tree and > open documentation and have a look at its methods listed there.

probably a wee typo, but hope that gets you back on track.