Is repeat until outdated?

I wanted to incorporate this loop into my script but I can’t find official roblox documentation on it, which makes me question if its outdated at this point? If there is official roblox documentation please link me it, that would be great.

ROBLOX doesn’t have an official documentation on repeat loops, but that doesn’t mean you shouldn’t use them!

repeat loops can still be useful, for example:

local Camera = workspace.CurrentCamera

repeat
    Camera.CameraType = Enum.CameraType.Scriptable
    task.wait()
until Camera == Enum.CameraType.Scriptable

Waiting for a camera to set its’ CameraType to scriptable can be done by using a repeat loop, since the CameraType is set to Custom constantly when a players’ Character loads.

If you want documentation on repeat loops, then I suggest looking at the official Lua wiki.

I wouldn’t say that repeat until is outdated. It really is just a variation of the while loop, the difference being the check comes after the loop has executed its code instead of before. So if you are thinking using this loop just make sure that behavior is what you want. I don’t know why its not in the official documentation, but I assume its maybe because you can get around this behavior pretty easy with the while loop only. The difference can be show here:

while [[CONDITION == true]]] do -- Check is here, the code may not run if its not initially true
	-- Loop code here
end
repeat
	-- Loop code here
until [[CONDITION == true]] -- Check is after the code is run, the code will always run once no matter if the condition is true or false
1 Like