No error but still not working

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

MenuButton function is working but RestartButton function is not working.Why is it not working.Also this is stop menu scene and I’m putting it in every level

func _on_RestartButton_pressed():
>$RestButton.frame = 1
>yield(get_tree().create_timer(0.2),“timeout”)
>get_tree().reload_current_scene()
>print(“restart”)

func _on_MenuButton_pressed():
>$MenButton.frame = 1
>yield(get_tree().create_timer(0.2),“timeout”)
>get_tree().change_scene(“res://Scenes/UI/MainMenu.tscn”)

:bust_in_silhouette: Reply From: Inces

What do You mean no error ? No error in console ?
reloadcurrentscene returns information on why the scene could not be reloaded. Just print(reloadcurrentscene())

It’s not allowing me to print a function

The method “reload_current_scene” isn’t declared in the current class.

MemokingMH | 2021-03-24 16:28

You weren’t supposed to print it literally, You repeated my typo’s :slight_smile:

Look at the function You used in documentation. It says it returns ERROR when something goes wrong. It says, that there are 3 possible errors when scene does not reload - no current scene defined, impossible to instantiate scene, impossible to get packed scene. You need to use print to get and read this error. SOmething like this :

If get_tree().reload_current_scene() == 1:
      print("error nr 1")
elif get_tree().reload_current_scene() == 2:
     print("error nr 2")

and so You will know why it does not work

Inces | 2021-03-24 18:29