So recently when I was making this tutorial and I thought to myself why not use os or tick to make an accurate waiting time. So I decided to make it with os.clock(). It seemed to work perfectly and I made a small demo of it. The demo isn’t perfect because of human error(I think).
Here’s my module script :
local osRealWait = {}
local OS_CLOCKValue = script["os.clock()"]
return function(Wait_Time : number)
local NowTime = os.clock()
local ProjectedTime = NowTime + Wait_Time
repeat task.wait()
until OS_CLOCKValue.Value >= ProjectedTime
end
Inside the module I have a value and a script in the value changing the value’s value to the current os.clock() time.
I don’t see why this is more practical than task.wait(). What you’re doing is creating a more inefficient version of task.wait() because task.wait() is based on heartbeat. It’s very rare that you would need something to yield at an accuracy higher than that error margin.
In all honest I have absolutely no idea what you are trying to do here.
Why on earth are you trying to get an accurate wait time?
Side note: wait() is quicker that task.wait() since the latter is yielded until the next frame whilst the first one isn’t. wait() is affected by throttling that is why using task.wait() is generally better.