extends Node func saveJSON(): var save_path = str("user://player_data"+$input_id.text+".json") var data := { "name": $input_name.text, "hp": $input_hp.text, "level": $input_level.text } var json_string = JSON.stringify(data) var file_access = FileAccess.open(save_path, FileAccess.WRITE) if not file_access: print("An error happened while saving data: ", FileAccess.get_open_error()) return file_access.store_line(json_string) file_access.close() func _on_button_pressed(): saveJSON() func _process(delta): if Input.is_action_pressed("escape"): get_tree().change_scene_to_file("res://scenes/menu/main.tscn")