Is there a way to execute a function every few secs
Re: Is there a way to execute a function every few secs
If you're looking for a way to essentially run a function "in the background" while other things are happening, you'll need to integrate it into whatever event loop is running at the time. Just make sure your wait has a timeout, and check your timer to see if it's time to run the function. Something like:
next_call_time = 0 while true wait(100, msgport) t = timer.TotalSeconds() if t > next_call_time then next_call_time = t + interval call_my_function() end if ... rest of event loop ....