Changing scenes when you have multiple maps

Godot Version

4.2.1

Question

Hello, I'm trying to make my first RPG game with Godot and I had some problems changing scenes when I have multiple maps. Let me explain, I have recently made two worlds and connected those two like this:

func _on_bar_transition_point_body_entered(body):
if body.has_method(“leazar_springs”):
Global.transition_scene = true

func _on_bar_transition_point_body_exited(body):
if body.has_method(“leazar_springs”):
Global.transition_scene = false

func change_scene():
if Global.transition_scene == true:
if Global.current_scene == “mundo_1”:
get_tree().change_scene_to_file(“res://Scenes/bar.tscn”)
Global.finish_changescenes()

func _on_bar_transition_point_body_entered(body):
if body.has_method(“leazar_springs”):
Global.transition_scene = true

func _on_bar_transition_point_body_exited(body):
if body.has_method(“leazar_springs”):
Global.transition_scene = false

func change_scene():
if Global.transition_scene == true:
if Global.current_scene == “mundo_1”:
get_tree().change_scene_to_file(“res://Scenes/bar.tscn”)
Global.finish_changescenes()

It all works, so I continued writing the code so my character could go to a third map which has to be connceted to the second. I thought if I did the same as I did with the two previous worlds changing the variables and the functions it would work, but it doesn’t. This is what I wrote:

func _on_bar_exitpoint_body_entered(body):
if body.has_method(“leazar_springs”):
Global.transition_scenebar = true

func _on_bar_exitpoint_body_exited(body):
if body.has_method(“leazar_springs”):
Global.transition_scenebar = false

func change_scenebar():
if Global.transition_scenebar == true:
if Global.current_scene == “bar”:
get_tree().change_scene_to_file(“res://Scenes/pueblo.tscn”)
Global.finish_changescenesbar()

It should change scene to ‘pueblo’ like I just did to the other map, but instead of that it doesn’t do anything at all. What should I do? Is there something I’m missing?

I solved it by making a global variable for every transition.

Any reason why you don’t call change_scene_to_file directly? :thinking:

func _on_bar_transition_point_body_entered(body):
    if body.has_method(“leazar_springs”):
        get_tree().change_scene_to_file(“res://Scenes/bar.tscn”)