Why use do end, in the end it can solve any problem then;
do-end blocks it solves a variable scope issue, we must first understand the local and global variables have completely different lexical scope; we should try to declare local variables to minimize the scope of a variable range to only It exists within the range of variables they need, and do not pollute the environment within the wider public;
Referring first to look at two examples:
do
local x1=1
local x2=2
local sum=x1+x2
end
print(x1,x2) --nil nil
Do not do end:
local x1=1
local x2=2
local sum=x1+x2
print(x1,x2) --1 2