Stop using wait(), use this instead!!!

We know that in Roblox, to yield a part of the code, we use functions like wait() (or :Wait() when dealing with events). However, did you know that wait() method is deprecated and can cause longer delays than you might expect?
This is where the task library comes into place. It allows you to talk directly with roblox engineβs task scheduler to manage and schedule code. It is much optimized option.
But how to use the task library?
The Task library is used for multiple existing methods like: wait(), spawn(), defer(), and delay(). It also adds new ones like task.desynchronize() and task.synchronize().
To update deprecated methods using the Task library, simply add the prefix: "task" to the method. The new methods are listed below:
β’ task.wait()
β’ task.defer()
β’ task.delay()
β’ task.spawn()
If you want to learn more, check the following link: https://devforum.roblox.com/t/task-library-now-available/1387845
Hope this helped!