Just use a global variable. This should have been the first thing on your mind if you had a real idea of how to use GML.
At the start of the game, set up the global variable:
Then you can get credits like this:
Or spend credits like this (also checking that there's enough):
Code:
if (global.credits >= 100) {
global.credits -= 100;
/* Actions for spending 100 credits */
}
Or save the current credits like this (one of many ways):
Code:
ini_open(working_directory + "progress.ini");
ini_write_real("progress", "score", global.credits);
ini_close();
Or load the saved credits like this (corresponding to the above):
Code:
ini_open(working_directory + "progress.ini");
global.credits = ini_read_real("progress", "score", 0);
ini_close();