How laggy is while true do

There’s no noticeable benefit to using while true do --code wait() end - or connecting the function to RunService.Heartbeat, for that matter - over putting the same code in a loop that runs at a lower frequency. Checking if characters are in a zone 10 times every second will feel just as responsive to players as checking it 40 to 60 times a second, and will free up resources on the server.

local CHECK_FREQUENCY = 10 --Frequency at which we check for players in the zone, in hertz.

while task.wait(1/CHECK_FREQUENCY) do
  --Check for player characters
end

However, I’d recommend using a module such as ZonePlus over checking a Region3 10 times a second.

1 Like