Get_tree().change_scene_to_file not found in base Callable?

Godot Version

4.6

Question

Hello!!

I’m trying to get my game to change scenes once the player reaches a certain score. Im certain the game is registering when the player reaches said score, because it will print when i say ‘if score is over X number’ (not exactly that, but point still stands). It keeps giving me the error “Cannot find member “change_scene_to_file” in base “Callable”.” I’ve tried it two different ways, and it still hasnt worked. Any thoughts?

Try one:

func _score():
	if left.score > 14:
    get_tree.change_scene_to_file("res://Scenes/minigame2.tscn")

Try two (I put a global variable to try and change it that way)

#root node, original global variable is set to false before this.

func _score():
	if left.score > 14:
		change_scene = true
#its a juggling game, for clarity, but this si on the one ring i have to juggle.

func _ready():
	blue_ring.visible = false
	animationplayer.pause()
	if Globals.change_scene != false:
		get_tree.change_scene_to_file("res://Scenes/minigame2.tscn")

get_tree() is a function. You need to call it to get the reference to the scene tree.

1 Like

get_tree().change_scene_to_file(“res://Scenes/minigame2.tscn”)

You missed the parentheses after get_tree is what he was referring to.

1 Like

thank you!!! I cant believe i missed that, ive done the same function a million times before :,D