How to save a single script file

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

I have a singleton with 5 variables, how can I make their changes permanent? Like a save and load script, and where should I put that script? (on the player’s script?)

Not sure if I can follow… You want to save (the variables in your singleton script to a file?) but don’t load them when the game is started back? Why save them then?

njamster | 2020-06-18 12:54

changed the question, I wrote it badly

MightyRat | 2020-06-18 23:54

:bust_in_silhouette: Reply From: MaaaxiKing

I also don’t understand why saving but not loading but look here.

:bust_in_silhouette: Reply From: rakkarage
extends Node

const _path := "user://Store.cfg"
var _file :=
var _dataDefault := {
	"all": {
		"remember": true,
	"f": {
		"token": "",
		"email": "",
		"refresh": "",
		"id": ""
	"n": {
		"token": "",
		"email": ""
var data := _dataDefault.duplicate()

func _init() -> void:

func read() -> void:
	if _file.load(_path) == OK:
		for section in data.keys():
			for key in data[section]:
				data[section][key] = _file.get_value(section, key)

func write() -> void:
	for section in data.keys():
		for key in data[section]:
			_file.set_value(section, key, data[section][key])

func clear() -> void:
	data = _dataDefault.duplicate() = "test"

rakkarage | 2020-06-18 14:49