Reload_scene_tree() is not reloading the scene, no idea why

Hi,
I am going through the Discovering Godot course. I got to the point where i need to reload the scene but the line get_tree().reload_current_scene() doesn’t work for me, the scene doesn’t seem to reload at all as the Line Editor never shows up again and nothing seems to be reloaded/reactivated. I used a break point and the line does execute with no exceptions. Any idea why it doesn’t work?

here is the code:

extends Control

onready var DisplayText: Node = $VBoxContainer/DisplayText
onready var PlayerText: Node = $VBoxContainer/HBoxContainer/PlayerText

var words: Array
var prompts: Array = ["verb","adjective","adjective"]
var story = "the sad monk went %s and then became %s when he ended his journey he became %s"


func _ready():
	DisplayText.text = "Welcome to Looney Lips "
	check_words_input()


func _on_PlayerText_text_entered(new_text: String):
	get_word()


func _on_Button_pressed():
	if is_story_done():
		reset_game()
	else:
		get_word()


func get_word():
	add_player_word()
	check_words_input()


func is_story_done():
	return words.size() == prompts.size()


func add_player_word():
	words.append(PlayerText.text)
	DisplayText.text = ""
	PlayerText.clear()


func tell_story():
	DisplayText.text = story % words


func show_prompt():
	DisplayText.text += "Please write a " + prompts[words.size()]


func check_words_input():
	if (is_story_done()):
		end_game()
	else:
		show_prompt()


func end_game():
	PlayerText.queue_free()
	tell_story()

func reset_game():
	get_tree().reload_current_scene()

I’d pop a print log to see when the button is pressed if the game has ended it calls the function to reset the game.
Often backtracing a bug like this to its origin can help :slight_smile:

The line of code absolutely runs with a return code 0 and still nothing reloads

No one has any clue what could be going on here? i am still stumped with this.

i tried rewriting the reset_game() function here are the two versions

func reset_game():
	PlayerText.show()
	get_tree().reload_current_scene()
	SubmitLabel.text = "OK"

This one didn’t do anything, the function was executed but the label didn’t change, the text didn’t show and most of all the scene didn’t reload and yet the next one worked perfectly

func reset_game():
	PlayerText.show()
	SubmitLabel.text = "OK"

There is no doubt about it the get_tree().reload_current_scene() doesn’t work and probably breaks something(which is why the original code didn’t work), maybe some bug in the engine?

This just suddenly works now. No clue what changed, maybe an update?

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms