[Resolved] Score doesn't get removed >:(

On my gameover screen, when I click the retry button, the game restarts as well as the score, but when I click the menu button, it goes to the menu but the score stays on the screen.

Here’s the code in the game.

score = require("score")  
local scoreInfo = score.getInfo()  
score.init( {   
 x = 140,   
 y = 5 })  

And here’s my gameover screen

module(..., package.seeall)  
  
-- Main function - MUST return a display.newGroup()  
function new()  
 local localGroup = display.newGroup()  
----------------------------------------------------------------------  
local ui = require "ui"  
local facebook = require("facebook")  
local json = require("json")  
local tableView = require("tableView")  
local widget = require "widget"  
  
--finalscore = score.getScore()  
  
----------------------------------------------------------------------  
-- SCENE SETUP --  
----------------------------------------------------------------------  
local background = display.newImage ("charbg.png")  
localGroup:insert(background)  
-- Sets the background and inserts it into localGroup  
  
local busted2 = display.newText("Quit Buggin Out Man!", 37, 26.7, "SweetLeaf", 43.5)   
busted2:setTextColor( 255, 0, 0 )   
localGroup:insert(busted2)  
  
local busted = display.newText("Quit Buggin Out Man!", 35, 25, "SweetLeaf", 44)   
busted:setTextColor( 0, 0, 255 )   
localGroup:insert(busted)   
local function onRetry( event )   
 if event.phase == "release" then   
  
 director:changeScene("gameATilt")   
  
 end   
end   
local retryBtn = widget.newButton{  
 label = "Retry",  
 defaultColor = { 34, 34, 34, 255 },  
 overColor = { 129, 122, 128, 100 },  
 strokeColor = { 164, 198, 57, 255 },  
 strokeWidth = 1,  
 font = "Spliffs",  
 fontSize = 28,  
 yOffset = -14,  
 labelColor = { default={ 102, 255, 0, 255 }, over={ 164, 198, 57} },  
 emboss = true,   
 width = 150, height = 45,  
 id = "retryBtn",   
 onRelease = onRetry  
}   
retryBtn.x = 150   
retryBtn.y = display.contentHeight/2 + retryBtn.height\*2  
localGroup: insert(retryBtn)   
local function onMenu( event )   
 if event.phase == "release" then   
  
 director:changeScene("menu2")   
  
 end   
end   
  
 local menuBtn = widget.newButton{   
 label = "Menu",   
 defaultColor = { 34, 34, 34, 255 },   
 overColor = { 129, 122, 128, 100},   
 strokeColor = { 164, 198, 57, 255 },   
 strokeWidth = 1,   
 font = "Spliffs",   
 fontSize = 28,   
 yOffset = -10,   
 labelColor = { default = { 102, 255, 0, 255 }, over = { 164, 198, 57} },   
 emboss = true,  
 width = 150, height = 45,   
 id = "menuBtn",   
 onRelease = onMenu  
}   
menuBtn.x = 355  
menuBtn.y = display.contentHeight/2 + menuBtn.height\*2  
localGroup: insert(menuBtn)   
  
 return localGroup  
end  

[import]uid: 114389 topic_id: 30440 reply_id: 330440[/import]

Since you are using Director, it will only remove the score if you insert the score’s display object into localGroup. If you can’t get access to the score’s view/display object, you will need to manually remove it when the scene exits.

There is a :clean() function that gets called when Director shifts the scene out of memory to remove things not in the localGroup display group, like timers, and such. This is where you could remove the score. [import]uid: 19626 topic_id: 30440 reply_id: 122001[/import]

Oh okay, that you very much. [import]uid: 114389 topic_id: 30440 reply_id: 122512[/import]

Since you are using Director, it will only remove the score if you insert the score’s display object into localGroup. If you can’t get access to the score’s view/display object, you will need to manually remove it when the scene exits.

There is a :clean() function that gets called when Director shifts the scene out of memory to remove things not in the localGroup display group, like timers, and such. This is where you could remove the score. [import]uid: 19626 topic_id: 30440 reply_id: 122001[/import]

Oh okay, that you very much. [import]uid: 114389 topic_id: 30440 reply_id: 122512[/import]