(bootleg showcase)
do you have that seething annoyance in roblox’s systems not allowing you to wait in milliseconds? do you need that milisecond perfect time? well, fear not, i have made this system that allows you to do jsut that. although you may need to use this whenever needed, as it can result in problems that is locked to the roblox’s task scheduler
introducing (a botched) MilliWait() function!
which does exactly what it does, it waits in millisecond time.
local function MiliWait(Time) -- the time parameter is the amount of time you want to wait
local NOW = os.clock() -- gets the current time when the function is ran
local Time = Time * 0.001
local dt
repeat
dt = task.wait()
until os.clock() + dt >= NOW + Time
-- task scheduler reliant
-- will check the current delta time, multiply it by two, and check if
-- the time is ahead of the expected end.
-- if it is, it goes to the next line which does...
repeat
if true then end
until NOW + Time <= os.clock()
-- this, and will run this until it finishes the wait.
end
i haven’t really tested this out too much, but it’s most likely going to be broken by a bit due to lag spikes.
there is a chance if your computer is pretty slow, the task scheduler reliant algorithm will overshoot, and immediately run the resource intensive, performance reliant one. but i don’t know if this is actually true as well, so maybe test it for yourself?
if you wondered why there was a “if true then end” in the last thing, i have no idea, i just put it there so it wouldn’t be much of a problem. but this is pretty much not deep tested, so please if you could test it, show the results!
if you want to improve upon this, please send your solution in the thread!
i am eager to find new solutions to this problem. so thank you for your cooperation if you do wish to help me and the others.
By Shiroi.
(edit, i changed the code a bit for a performance boost)
(edited it so it takes in 500ms for 0.5s instead of 0.5s for 0.5s)