0
\$\begingroup\$

I need to make a button that restarts the scene. i tried

func reset():
    if Input.is_action_just_pressed('reset'):
        get_tree().reload_current_scene()

But this doesn't work- any advice? All i need is the button to reset the scene

\$\endgroup\$
2
  • 2
    \$\begingroup\$ And what did not work exactly? Your function did not get called? Your scene did not reset? You got an error? \$\endgroup\$
    – Zibelas
    Feb 21, 2023 at 19:01
  • \$\begingroup\$ I'd venture to guess nothing is calling the reset function. Edit: You can use a breakpoint or a print statement to verify if the function is getting executed. \$\endgroup\$
    – Theraot
    Feb 22, 2023 at 0:26

1 Answer 1

0
\$\begingroup\$

Your code seems correct, but you actually must have the code to be called for it to have any effect. Place your two lines of code within a node's (or autoload's) _process() function and it should work.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .