I thought it would just be easier to duplicate scenes when creating multiple levels, however all my scripts are based on level 1, so my buttons when pressing play again when the level has ended - based on completing it or dying, on my other levels, will automatically go to level 1, because of the duplicated script.
Is there a way I can use a global variable to check what scene it was just on, and then make the button go to that most recent scene? Thank you.
extends Node2D
func _on_button_pressed() → void:
get_tree().change_scene_to_file(“res://scenes/…. # i want this to go the scene it was currently on
func _on_button_2_pressed() → void:
get_tree().change_scene_to_file(“res://scenes/Levels.tscn”)