0 votes

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 onRestartButton_pressed():

$RestButton.frame = 1
yield(gettree().createtimer(0.2),"timeout")
gettree().reloadcurrent_scene()
print("restart")

func onMenuButton_pressed():

$MenButton.frame = 1
yield(gettree().createtimer(0.2),"timeout")
gettree().changescene("res://Scenes/UI/MainMenu.tscn")

Godot version 3.2
in Engine by (44 points)

1 Answer

–1 vote

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

by (1,154 points)

It's not allowing me to print a function

The method "reloadcurrentscene" isn't declared in the current class.

You weren't supposed to print it literally, You repeated my typo's :)

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.