I’m working on a game, and I want to save the highscore in a text file, so I made a function to set the highscore in that textfile:
[lua]function setHighScore( val )
local file = io.open( filePath, “w” )
file:write( tostring(val) )
io.close( file )
file = nil
end[/lua]
When I call it, I get this error: “attempt to index local file (a nil value)…”
and that’s not all. When I call it from the scene:create, it works just fine, but when I call it from another function, it throws that error. What can I do?