Can you post the code where you load and save the score?
I actually tried your code before and it worked for me fine in the simulator:
score.lua
local M = {} -- Create the local module table (this will hold our functions and data) M.score = 0 M.filename = "score.txt" function M.set( value ) M.score = value M.scoreText = string.format( "% 6d", M.score ) end function M.get() return M.score end function M.add( amount ) M.score = M.score + amount M.scoreText = string.format( "% 6d" , M.score ) end function M.save() local path = system.pathForFile( M.filename, system.DocumentsDirectory ) local file = io.open(path, "w") if ( file ) then local contents = tostring( M.score ) file:write( contents ) io.close( file ) return true else print( "Error: could not read ", M.filename, "." ) return false end end function M.load() local path = system.pathForFile( M.filename, system.DocumentsDirectory ) local contents = "" local file = io.open( path, "r" ) if ( file ) then -- Read all contents of file into a string local contents = file:read( "\*a" ) local score = tonumber(contents); io.close( file ) return score else print( "Error: could not read scores from ", M.filename, "." ) end return nil end return M
main.lua
----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- -- Your code here local score = require("score") local function saveScore() score.set( 2 ) score.save() end local function loadScore() local s = score.load() score.set( s ) print("Current score: ", score.get() ) end -- Call this on your first try to set and save the score: -- saveScore() -- Call this on your second try to load the score: -- loadScore()