0 votes

Hello! When I use the method "gettree().reloadcurrent_scene()" I get the following warning:

The function 'reload_current_scene()' returns a value, but this value is never used.

What does this method return?

in Engine by (94 points)

1 Answer

+1 vote
Best answer

So, it is just that, a warning. Really, Godot is telling you that the method reload_current_scene() returns a value (in this case, an Error code indicating whether the call succeeded or not) that you are not using in your code.

While you don't have to use the return value, it's just telling you that there is a return value that you could be using. If you don't want to use the value, and you don't want to see the warning, you can ignore it by:

  • Select the small warning icon just below your source code

    • Click the "ignore" link on the specific warning you want to ignore.

But, you can also choose to do nothing as the warning doesn't hurt anything.

Edit: I just noticed you're asking what the method returns. There's no better place to find that out than the documentation. It's an Error enum value. See here for details:


by (21,800 points)
selected by

Thanks for the answer! The thing is that it's kinda annoying to have this warning, so I'm trying to figure it out what to do since I have no variable to receive the value of reload_current_scene()

So, you can just create a variable to store the value in...

var result = get_tree().reload_current_scene()

However, then Godot will complain that you have a local variable declared that's not used. To mitigate that, prefix the variable name with an underscore. So, the final solution is this:

var _result = get_tree().reload_current_scene()

Thanks for the answer! I decided to print the return value.

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 Frequently asked questions and 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 [email protected] with your username.