how can change back my position?

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

what i want do to is, when i click 1 out 7 button ,my position2d at button location will go down by -20. then when i click another button , the previous position2d will return to original position. how should i do it?

var current_player_pos
func _ready() -> void:
	for checkbox in get_tree().get_nodes_in_group("character_checkbox"):
		checkbox.connect("pressed",self,"checkbox_data",[checkbox.get_name()])

		current_player_pos = get_node(player_slot_path + checkbox.name + "/" + checkbox.name + "_pos" ).global_position.y

func checkbox_data(checkbox):
	
	
	if get_node(player_slot_path + checkbox + "/" + checkbox + "_pos" ).name == checkbox + str("_pos"): #if sprite and box same
		prev_player_sprite = get_node(player_slot_path + checkbox + "/" + checkbox + "_pos" )
		
		if get_node(player_slot_path + checkbox + "/" + checkbox + "_pos" ).global_position.y == current_player_pos:#if sprite pos and box pos same
			
			get_node(player_slot_path + checkbox + "/" + checkbox + "_pos" ).global_position.y += 20
			
	else:
		pass

my tree like thisenter image description here

:bust_in_silhouette: Reply From: Bot7

you should sa ve the previous position in a variable before the object is moving. this video can maybe help you https://www.youtube.com/watch?v=kwbPThtHbvA