How does the ROBLOX function 'do' work?

do isn’t a function. do end defines a new scope. lua-users wiki: Scope Tutorial

local hello = "hi"

do
     local world = "world"

     print(hello, world) --// "hi", "world"
end

print(hello, world) --// "hi", "nil"

world is nil in the outer scope.

5 Likes