hey guys sorry for being a bug but i am having trouble saving my high score. my high score like this
highscore = 0 score =0 local function save( event ) -- function to save score local path = system.pathForFile( "score.txt", system.DocumentsDirectory ) -- where the file will be saved local file = io.open( path, "w+b" ) -- opening the file file:write(highscore.."") -- writing the variable 'score' in the score.txt file io.close( file ) -- closing the file -- Saves our data end local function resumeStart() local path = system.pathForFile( "score.txt", system.DocumentsDirectory ) -- where the file will be saved local file = io.open( path, "r" ) -- opens the file under the variable file if file then -- if there is a file then local contents = file:read( "\*a" ) -- read the contents of the file, and read the whole string(\*a) local prevState = explode(", ", contents) -- put the contents of score.txt into a table print('file') highscore = prevState[1] -- read the table at position 1 and assign the variable score io.close( file ) -- close file else -- if there is no file highscore=0 -- the score then starts at 0 end end --ANSCA sample code-- function explode(div,str) if (div=='') then return false end local pos,arr = 0,{} -- for each divider found for st,sp in function() return string.find(str,div,pos,true) end do table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider pos = sp + 1 -- Jump past current divider end table.insert(arr,string.sub(str,pos)) -- Attach chars right of last divider return arr end --ANSCA sample code^-- resumeStart() -- call the starting function function scoreUpdate(event) score = score +100 scoreText.text = ""..score ---scoreText:setTextColor(225,225,225) --scoreText:setReferencePoint(display.TopLeftReferencePoint) scoreText.x = 150 scoreText.y = 40 if highscore \< score then print "highscore" highscore = highscore +100 highscoreText.text = ""..highscore --scores:increment( "player2") --scores:save() save() end end
the problem is i want to compare two value the high score and score it self like this
if highscore \< score then print "highscore" highscore = highscore +100 highscoreText.text = ""..highscore save() end
but i keep getting this error “attempt to compare string with number”
also could i just use Apple or google leaderboard system to save my high scores? i am very lost on this please help.
i even try using ice box but no luck 
thanks
from Sean 