While loop vs Run Service for 1/10s timer?

I saw multiple topics like this, but most of them simply argue that one is better than other, but no one talks what about situations where we don’t need to run script every 1/60 of a second but rather 1/10?

1 Like
while task.wait(0.1) do
    blabla()
end

Don’t overcomplicate it

1 Like

To put it very simply, if you don’t need something run every frame, don’t use runservice for it. There are certain cases which are exempt from this, but generally this is the jist.

If you need something run every 1/10th of a second, use a while loop with task.wait. task.wait can wait up to 1/frame rate, because it waits until the next frame of which that time limit has passed.


Don’t mean to be that guy, but this is generally considered as a better structure for that:

while true do
    task.wait(0.1)
end
1 Like

I mean probably yeah lol

chars

thx, sry for asking but when i see everyone tell: Use run service because it’s better without giving reason you really can’t see which one to use, thx

its fine for asking! This category is for help. Run service is particularly useful when you want to bind an action to framerate without interrupting your main code flow, and it also provides useful things like the time between frames (delta time), and things like what order in the main flow they can run in.

1 Like

using task.spawn will do too i think, anyways thx for help everyone :}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.