Problem in a menu system

Hello, I just implemented local highscore for my game. And also have put a Rank menu to show the top score, it works really properly.

But(haha, there is always a but), if I play the game, looses it(it’ll appear a Restart and a Menu button) and I click the Menu button, If i go to see the ranking, I get a director class error.

Now, I don’t know if my problem is in score.lua, menu.lua or game.lua.

And the terminal doesn’t show anything in error.

This is all I get:

[lua]-----------------------
–Director ERROR: Failed to load module ‘score’ - Please check if the file exists and it is correct.–
-----------------------[/lua]
Thank you for the support and the patience. [import]uid: 69287 topic_id: 13044 reply_id: 313044[/import]

So you click the menu button then another button, which is when you get the problem - what does the ranking button do? (You say you “go to see the ranking” and it fails.) [import]uid: 52491 topic_id: 13044 reply_id: 47964[/import]

Hi, sorry for waiting too long for answering.

Well, let me see if I can explain with more details.
First screen: Menu
Menu have 2 buttons, a Play and a Ranking button.
If I click the play, the game starts(in another screen, obviously).
If I click the ranking, the ranking shows up(in another screen too).

The problem is, if I click play, and then I loose the game, and get back to the Menu(by a button at the gameover.lua file), I can’t click the Ranking button, it gives the error I said in the beginning of the topic.

The only thing that the ranking button function does is:

[lua]local function changeScene(e)
if(e.phase == “ended”) then
director:changeScene(e.target.scene)
end
end[/lua]

Thanks for your patience and your support. [import]uid: 69287 topic_id: 13044 reply_id: 48138[/import]

Is score.lua the one from sample code or is it your scene for ranking? It seems to be a score issue, at least from your error - that’s very specific. [import]uid: 52491 topic_id: 13044 reply_id: 48173[/import]

Hi!
This is my score.lua!

[lua]module(…, package.seeall)
function new()
local Scene = display.newGroup()
local interface = display.newGroup()
local filePath = system.pathForFile(“score.txt”, system.DocumentsDirectory)
local file = io.open( filePath, “r”)
local maiorplacar = 0
if file then
maiorplacar = file:read("*n")
io.close(file)
end
local maiorplacartxt = display.newText("Maior Placar: " … maiorplacar, 0, 0, native.systemFont, 16)
maiorplacartxt.x = _W / 2
maiorplacartxt.y = _H / 2
local frame = display.newRect(0, 0, 154, 154)
frame.x = _W / 2
frame.y = _H / 2 + 100
local botaovoltar = display.newRect(0, 0, 150, 150)
botaovoltar.x = _W / 2
botaovoltar.y = _H / 2 + 100
botaovoltar:setFillColor(0, 0, 0)
local text = display.newText(“Menu”, 0, 0, native.systemFont, 40)
text.x = _W / 2
text.y = _H / 2 + 100
botaovoltar.scene = “menu”
local function funcao(e)
director:changeScene(e.target.scene)
end
botaovoltar:addEventListener(“tap”, funcao)
interface:insert(frame)
interface:insert(maiorplacartxt)
interface:insert(botaovoltar)
interface:insert(text)
Scene:insert(interface)
return Scene
end[/lua] [import]uid: 69287 topic_id: 13044 reply_id: 48176[/import]

And you’ve already called this once when you have get the error, so I guess something is likely carrying over that shouldn’t be. Have you checked to make sure everything related to score.lua has been removed/cancelled/etc before calling it again? [import]uid: 52491 topic_id: 13044 reply_id: 48317[/import]