can_process: "!is_inside_tree()" is true. Returned: false

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By p3drac0

Hey, I’m new and I was doing several tutorials when i found the error in the title

I wrote a code where if a ball gets out of the screen, several things happen:

func _on_VisibilityNotifier2D_screen_exited():
var replay_scn = load("res://title/replay.tscn")
get_tree().paused = true


there is a part of the code when I press a button

func _input(event):
if event.is_action_pressed("iniciar") and not iniciado :
elif event.is_action_pressed("iniciar") and iniciado==true :
	get_tree().change_scene("res://World.tscn") ###ERROR HAPPENS HERE####

When I change the scene in this point, the following error appears

can_process: “!is_inside_tree()” is true. Returned: false

and after that I am not able to unpause the game and it freezes

I am also noob in terms of formullating questions, so if you need more information, i’ll give you.

Ty guys and sorry for bad indentation in code copying

:bust_in_silhouette: Reply From: bloodsign

I don’t have the exact answer to your problem, but I stumbled across on that error myself.
It usually happens when you instance something, apply properties to it before adding it to the scene tree(sorry if I made it more confusing, English isn’t really my first language). To illustrate:

var camera_pck = preload("res://custom_camera.tscn")
var camera = camera_pck.instance

camera.global_position.x = 900

These snippet of code would generate this error:

get_global_transform: Condition “!isinside_tree()” is true. Returned: get_transform()

In order to fix it I just move

camera.global_position.x = 900

after add_child(camera), likeso:

camera.global_position.x = 900