Fraustrating error fix pls

godot 3.2.2

this is not a error but its a warning but its important for my game.

this is the error: Line 5 (RETURN_VALUE_DISCARDED):The function ‘change_scene()’ returns a value, but this value is never used

this is my code:

extends Control

func _on_Play_again_pressed():
yield(get_tree().create_timer(3),“timeout”)
get_tree().change_scene(“res://game.tscn”)

func _on_Exit_pressed():
get_tree().quit()

This should work:

var error := get_tree().change_scene(“res://game.tscn”)
if error:
    print("Error while changing scene, error code: ", error)

As the documentation states:

Returns OK on success, ERR_CANT_OPEN if the path cannot be loaded into a PackedScene, or ERR_CANT_CREATE if that scene cannot be instantiated.

2 Likes

You can also ignore these warnings in project settings

1 Like