decrease delay rate in gamelooptimer

i have a delayRate variable which is set to 3000 

delayRate = 3000

then i have a gameLoopTimer variable which i declare at the very end of my code 

local gameLoopTimer

gameLoopTimer = timer.performWithDelay(delayRate, gameLoop, -1 ) 

i tried to  make a simple function that would decrease this delay rate 

local function delayRateDecrease() delayRate = 3000 if (score == 5) then delayRate = delayRate - 2900 end end

within this function is also where the delayRate is set equal to some value.

when i try to call the function in the gameLoopTimer in place of delayRate i receive an error

i tried several other basic things as well but even if the code runs without error it seems the delayRate doesn’t change 

 the Error i receive is “?:0 attempt to perform arithmetic on a nil value”

For the nil value error, make sure that the number being acted on is in scope and has been initialised.

A timer will only use the interval you first give it. The two choices are to cancel and restart the timer with the new value, or use an enterFrame listener to make your own timer.

  local delayRate = 3000 local lastIterationTime = system.getTimer()   local myDecreasingRateFunction = function (delayRate)      print ("Running after "..delayRate.." ms delay");    end   local gameLoop = function ()      if (system.getTimer() - lastIterationTime \>= delayRate) then          lastIterationTime = system.getTimer()     myDecreasingRateFunction(delayRate)          delayRate = delayRate - 200          end    end     Runtime:addEventListener("enterFrame", gameLoop)  

i added this in but i get a bit of a different error now. “attempt to perform arithmetic on string value”

Well the error tells you exactly what’s wrong - one of the variables involved in a calculation is not a number, but a string. If you know the line number then you know which variables to check. Make sure you’re not using the same name for two different things and overwriting a number with a string, or using the wrong name somewhere.