Unexpected error of function in scene:create

I have this error: attempt to perform arithmetic on upvalue ‘incTimeOver’ (a nil value)

On the line shown below

local incTimeOver local spawnColors -- create() function scene:create( event ) --left out stuff spawnColors = function ( event ) --check if difficulty needs to be increased incTimeOver = incTimeOver - spawnTime --line of error if incTimeOver \< 0 then incTimeOver = incTime increaseDifficulty() end end

Later on in the will show function I assign a value to the variable,
and in the did show function I call the spawnColors function.

I have spawnColors function in my create function so I could access the scene.group.
what I find weird is that I get a error of a nil value, and a the time the create function is called it is nill, but the function in it should not run so why do i get this error?

Can you edit your post to put the code in a code block, please?

EDIT:

Firstly, you can save a reference to scene.view by creating a display group at the top of your Lua file, then assigning scene.view to it in each of the composer functions.

Difficult to see what’s going wrong without seeing the will/did show code to see how incTimeOver is initialised.

I figured it out.

What the problem was is that I changed a name so incTimeOver was assigned nil.

Can you edit your post to put the code in a code block, please?

EDIT:

Firstly, you can save a reference to scene.view by creating a display group at the top of your Lua file, then assigning scene.view to it in each of the composer functions.

Difficult to see what’s going wrong without seeing the will/did show code to see how incTimeOver is initialised.

I figured it out.

What the problem was is that I changed a name so incTimeOver was assigned nil.