16. Read player input from an authored GUI
func run() -> bool:
var entered: String = str(GetGUIElementProperty(
"name_entry", "name_box", "text", ""
)).strip_edges()
if entered.is_empty():
SetGUIElementProperty("name_entry", "feedback", "text", "Enter a name.")
return false
Variable.player_name.value = entered
SetGUIElementProperty("name_entry", "feedback", "text", "Hello, " + entered + ".")
return true1. Create a GUI called name_entry with a Text Box named name_box, a Label named feedback, and a Confirm button.
2. Create a text variable player_name. Put the example in a native script record called accept_name.
3. On Confirm → Events → Click, choose Run Visual Script / Run Script and target accept_name. Leave the event’s Verb blank.
4. Validate and apply the script, save the GUI, show it during play, type a name and click Confirm.
Figure 4. The authored interface collects the name; its Confirm event calls the native GDScript record.
