Godot Version
4.2.1
Question
Hello, I’m trying to reload the main scene when my player dies (when the variable vida gets to 0) but using get_tree().reload_current_scene()
is giving me the following error:
Cannot call method ‘reload_current_scene’ on a null value.
This is my code:
if vida <= 0:
$"../CanvasLayer/ColorRect2/AnimationPlayer".play("restart")
has_died = true
died.emit()
await $"../CanvasLayer/ColorRect2/AnimationPlayer".animation_finished
get_tree().reload_current_scene()
Does anybody know how to do this?
Thanks.