Python has some special syntax that enables flow control that you could use, as you have referenced. It is called a “label”. You can read more about it in the docs. ::
However, this feature is not yet available in ROBLOX. It is expected that in v2.1.0 (soon) those will be made available, you can track the progress on the v2.1.0 github issue.
The other way you could use this is to jump inside an existing function from a Goto statement, like this unit_test()
local B = 1
print("a")
unit_test()
::START::
if B == 1 then
print("here")
B = 0
goto START
end
print("b")
end
However, this is not recommended. It reflects the way Lua is usually programmed (unlike Python, which is frequently written in a very clean and readable way by avoiding flow control)), and while it might make sense to someone who understands your code, it will only seem like a mess to those who don’t. The above example can just as easily be written like this: unit_test()
local B = 1
print("a")
unit_test()
print("here")
unit_test()
end
Many languages don’t use this as much as other languages due to its resulting messy logic. To futher explain why you shouldn’t use this:
Might make sense now, but in a larger script template, you will forget what you meants after a month
Very difficult for someone else to understand and improve your code without constantly asking you questions to explain what the code does, since the code isn’t written in a logical, easy to follow order
Anything beyond these 2 lines of ::START:: and if B == 1 then is impossible to have another goto START point to
The code could crash if a mistake is made in something like ::START:: pointing somewhere that there is no ::START:: label for
Feel free to ask for further clarification on anything.