why singleton just change next scene/map?

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

sorry for my broken english. and thank for help

when i click increase button in main map, number didt change, but when i change map, num_count change to right value. and same thing happend in second map, value did’t change until i go to other map. why this happend and how to fix it?

so i make 1 singelton and 3 scene
1 singelton name (global_object)with script:

  var num = 1

~scene~
1
i make node(bob)> label(num_count) with code:

func _ready():
	$num_count.set_text(str(int(global_object.num)))

2
main map

  • button for next_map with code:
func _on_next_map_pressed():
	get_tree().change_scene("res://new_world.tscn")

-button to increase number with code:

func _on_increase_pressed():
	global_object.num += 3

-and i put node(bob) from scene 1

3
second map name (new_world)

-button to increase number with code:

func _on_increase_pressed():
	global_object.num += 3

-put node(bob) from scene 1 here too