How to make a wait shorter than wait()?

so as far as i know the fastest wait you can do is wait()
i was wondering if there is anything you could do to make it even shorter, since the wait() is actually kinda slow

you can use the run service for it.
For example:

while game:GetService("RunService").Stepped:Wait() do
   print("e")
end

You can use RunService.Stepped I believe, which basically runs 1/60’ths of a second

game["Run Service"].Heartbeat:Wait()
-- also gives the exact time passed for the wait period (also called delta time)
local deltaTime = game["Run Service"].Heartbeat:Wait()

for local scripts you replace
Heartbeat
with
RenderStepped

There are no native support for anything lower than heartbeat and the likes.

You cant implement efficient function to yield either, it is usually hardware implemented.

You don’t need to replace Heartbeat with RenderStepped in localscripts and Heartbeat is mostly faster than Renderstepped if client is lagging anyways.

The only time I can see RenderStepped being faster than Heartbeat is when client is using some sort of FPS unlocker to reach frame rate that’s higher than 60 FPS.

It also runs even less than 1 / 60 if used on a client who is using an FPS unlocker (having more FPS than 60).

  • If a client is currently on exactly 240 FPS, then RunService.Heartbeat:Wait() will yield the thread for 1 / 240 seconds.
1 Like

Oh, first time I’ve heard this. Thanks for telling me :wink:

f03bdd8b0103a8f60573a665662180610402cf79_2_690x247 RenderStepped fires everytime before rendering stuff on the client and you can see the other events on this.

RenderStepped, Heartbeat and Stepped all fire at the same speed, except they differ at when they actually get fired internally the first time.

1 Like

Use RunService.RenderStepped:Wait() on clients, and RunService.Heartbeat:Wait()

These names are technically deprecated, but the new functions weren’t released yet.