What is the purpose of do-end code blocks in scripting?

I am currently working on my own Framework via modular code. In particular I am curious about the do-end code block, its functionality, and its use cases.

I could be wrong, but these two scripts seemingly do the same thing:

do
	print("test")
	-- other code
end
print("test")
-- other code

What is the difference? Is there any benefit in one over the other? What is a situation in which I would use a do-end code block?

1 Like

Its not necessary, but like the idea is to run a thing of code one time, people don’t use functions in this case because with functions you’re usually reusing it multiple times. I mean that’s really all it is. Very rarely would you have anything you’d want to run 1 time and even then id probably still use a for loop over do end. Just my personal preference though.

1 Like

Did some extra research and found it’s for variable scoping. This allows for local variables inside a code block, similar to a function, that is run one time.