I've seen this as the "Tip of the Day" but I forgot it. I'm sure someone knows; care to help?
It's the RenderStepped
event of the RunService
. This event fires every render frame, which is approximately 1/60th of a second. You can use it like a normal event (which will basically behave like a really fast loop, since the event is constantly firing.)
game:GetService("RunService").RenderStepped:connect(function() print("Spamming your output...") end)
Or simply use the wait() method, which will wait for the event to be fired until continuing.
while true do print("Spamming your output...") game:GetService("RunService").RenderStepped:wait() end
In a repeat loop, it's the same.
repeat print("Spamming your output...") game:GetService("RunService").RenderStepped:wait() until condition
This can only be used in a LocalScript.
here are some things faster than wait:
while true do print("thing") coroutine.yield() end runservice.RenderStepped:connect(function() print("thing") end) runservice.Heartbeat:connect(function() print("thing") end) local counter = 1 while true do print("thing") if counter == 2 then counter = 1 coroutine.yield() else counter = counter + 1 end end