Timer. Can I use performWithDelay function more than one?

Hey,

I have one question about timer.performWithDelay function . 

I wanted use it more than one. Like this:

local timer = timer.performWithDelay( 50, makeSomeMoves, 0 ) – move some object on the screen

local timer2 = timer.performWithDelay( 230, updateHPBar, 0 ) – updateHealthBar

But I get “attempt to call field  performWithDelay (a nil value)” error, why? I can only have one timer.performWithDelay at one time ?

Hi @mk691,

You can have any number of timers going at once (well, within practical reason, I suppose). The error you’re getting is not related to having more than one timer. Most likely, one of the listener functions that you’re specifying is undefined or not in the proper scope or some such issue.

Take care,

Brent

Given the error, I assume you have a typo with one of your  performWithDelay’s (so it ends up looking into the timer table with a bad key and finds nothing).

ok. Thanks for help

Hi @mk691,

You can have any number of timers going at once (well, within practical reason, I suppose). The error you’re getting is not related to having more than one timer. Most likely, one of the listener functions that you’re specifying is undefined or not in the proper scope or some such issue.

Take care,

Brent

Given the error, I assume you have a typo with one of your  performWithDelay’s (so it ends up looking into the timer table with a bad key and finds nothing).

ok. Thanks for help