Runtime error in dispatchEvent

function Model:addScore( scrplus )
score = score + scrplus
local event = {name = “SCORE_CHANGED”}
Runtime:dispatchEvent( event )
end

When i invoke Model:addScore( 0 ) function the runtime error appears:

Runtime error
?:0:attempt to index a nil file

How i can fix this problem? [import]uid: 95114 topic_id: 16226 reply_id: 316226[/import]

no idea why you get an error…

  1. is score defined somewhere and initialised to 0? if not then that is causing the error as it will have the default value of nil

  2. You surely do have Model as a table that has these functions addScore, etc… otherwise that is another point where you could get an error.

Lastly, it says index a nil file…

are you trying to read something from a file or something like that??

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 16226 reply_id: 60426[/import]