+1 vote

I have a script to changes the scene when a button is clicked. Because the scene that holds this script is preloading a scene that preloads the first scene, I get this error:

E 0:00:01.795   load: Resource: 'res://scenes/CityStreet.tscn' is already being loaded. Cyclic reference?

Is there a way to be able to reference scenes to each other without creating a cyclic reference?

The script in question:

extends TextureButton

export var next_scene_path: PackedScene

func _on_pressed():
    print("button pressed")
    transition()
    get_parent().queue_free()

func _get_configuration_warning() -> String:
    return "No scene loaded" if not next_scene_path else ""

func transition() -> void:
    var next_scene = next_scene_path.instance()
    get_tree().get_root().call_deferred("add_child", next_scene)
in Engine by (13 points)

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.

Categories