| Loop Type | Description | Example |
|---|---|---|
for loop |
Repeats a fixed number of times | for i = 1, 10 do ... end |
for loop (reverse) |
Counts down by steps | for i = 10, 1, -1 do ... end |
while loop |
Runs while a condition is true | while health > 0 do ... end |
repeat until loop |
Runs at least once, checks after each loop | repeat ... until ready == true |
| Loop Pattern | Use Case | Example |
|---|---|---|
ipairs loop |
Ordered list (array-style) | for i, item in ipairs(list) |
pairs loop |
Key-value table (dictionary-style) | for key, value in pairs(map) |
| Type | Description | Example |
|---|---|---|
| Infinite loop | Loop that runs forever (be careful!) | while true do ... end |
| RunService.Heartbeat | Runs every frame (great for animations) | RunService.Heartbeat:Connect(function()) |
| Stepped | Fires every simulation step | RunService.Stepped:Connect(function()) |
| RenderStepped | Fires every frame (client-side only) | RunService.RenderStepped:Connect(function()) |
Custom loop with wait() |
Pauses between iterations | while true do wait(1) ... end |