Hello, Developers!
I’m excited to share my first Community Resources post with yall. Today, I present UltraWait, a lightweight, high-performance module designed to address the limitations of traditional wait methods in Roblox.
Why UltraWait?
When it comes to precise timing in Roblox, both wait
and task.wait
can introduce noticeable inaccuracies, especially for sub-frame durations. For example:
-
task.wait(0.001)
may result in an actual wait time of ~0.016 seconds, depending on the device and frame rate.
This inaccuracy can be a dealbreaker for tasks that demand precise timing, such as animations, microsecond adjustments, or ultra-smooth visual effects.
That’s where UltraWait steps in. By combining os.clock()
and RunService.Heartbeat
, UltraWait achieves sub-frame precision with minimal CPU overhead.
Features
- Microsecond Precision
- Optimized Performance
- Lightweight and Robust
- Flexible Usage
How to Use UltraWait
- Add the
UltraWait
module toReplicatedStorage
(or any shared service). - Require the module in your script:
-- example:
local UltraWait = require(path.to.UltraWait)
local targetTime = 0.001
local realElapsed = UltraWait.wait(targetTime)
print(string.format("Target: %.3f, Actual: %.15f", targetTime, realElapsed))
Benchmarking
local UltraWait = require(game.ReplicatedStorage.UltraWait)
local targetTime = 0.001
-- UltraWait
local startUltraWait = os.clock()
UltraWait.wait(targetTime)
local elapsedUltraWait = os.clock() - startUltraWait
-- task.wait
local startTaskWait = os.clock()
task.wait(targetTime)
local elapsedTaskWait = os.clock() - startTaskWait
print(string.format("Expected: %.3f", targetTime))
print(string.format("UltraWait: %.15f", elapsedUltraWait))
print(string.format("task.wait: %.15f", elapsedTaskWait))
if elapsedUltraWait < elapsedTaskWait then
print("UltraWait wins")
else
print("task.wait wins")
end
Sample Output:
Get UltraWait:
UltraWait.rbxm (1.2 KB)
UltraWait - Creator Store
As this is my first Community Resources post, Id love to hear your thoughts! Feel free to:
- Share feedback about the module.
- Suggest improvements or use cases.
- Let me know how it performs in your projects.