Jump to content

OnTimer function for prefab


Maris

Recommended Posts

It looks like you're trying to set up a task to run every 1 second, right? Your above code will work perfectly, but there's a more direct way to set that up:

inst:DoPeriodicTask(1, function(inst)    -- Do something    -- ...end)
The DoTaskInTime function is appropriate if you want to do something once but delay it for a period of time.

DoPeriodicTask will do the task with the delay repeatedly until you cancel that task. You can store an instance of the Task like so:

inst.somethingTask = inst:DoPeriodicTask(1, function(inst)    -- Do something    -- ...end)
Then when you want to cancel the task, you can do:

inst.somethingTask:Cancel()
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...