attempt to call function 'grab_focus' in base 'null instance' on a null instance

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

I’m trying to make a pause screen, but I don’t know why it doesn’t work.

Any ideas

extends Control

func _ready():
$MarginContainer/CenterContainer/VBoxContainer/Texturebutton01.grab_focus()

func _physics_process(_delta):
if $MarginContainer/CenterContainer/VBoxContainer/TextureButton01.is_hovered() == true:
$MarginContainer/CenterContainer/VBoxContainer/TextureButton01.grab_focus()
if $MarginContainer/CenterContainer/VBoxContainer/TextureButton02.is_hovered() == true:
$MarginContainer/CenterContainer/VBoxContainer/TextureButton02.grab_focus()

func _input(event):
if event.is_action_pressed(“ui_cancel”):
$MarginContainer/CenterContainer/VBoxContainer/Texturebutton01.grab_focus()
get_tree().paused = not get_tree().pause
visible = not visible

:bust_in_silhouette: Reply From: Gabriel

In which line ‘grab_focus’ is not working?
Anyway, I noticed that there is a ‘Texturebutton01’ (with a ‘b’) and a ‘TextureButton01’ (with a ‘B’).
That’s probably what is wrong.

Ho my god¡¡

This is embarrassing … thank you very much. I am new to Godot … I have much to learn yet.
Thanks again.

David_sun | 2019-10-05 13:45