You can make it faster by adding an interations variable:
local maxIterations = 5 -- It will run the loop this many times before waiting
local iterations = 0
while true do
-- code
iterations += 1 -- Adding onto the iterations
if iterations == maxIterations then -- Checking if the threshold is passed
game:GetService("RunService").Heartbeat:Wait() -- Waiting
iterations = 0 -- Resetting
end
end
Although, this may not be beneficial to your use case(s).
The code is 30 lines long everything lays in the loop. The while loop is slower. The repeat until loop is equally fast but only on a smaller scale, as things scale up, it may get slower.
Take this with a grain of salt, as all of my proof could be proven invalid at any time.
You know it really isnt that hard if you want a faster loop then add a loop inside a loop or a run service inside of a run service think smarter not harder