I’m new to Roblox Lua but I have experience in other programming languages. I found many tutorials on the web, and all of the tutorials use local
to create variables – in the outermost scope. For example:
local someVariable = "foo"
local someVariableAgain = "bar"
function someFunction()
-- some code here
end
local
in the other programming languages I used, are used to hide variables from other scopes, so you won’t accidentally overwrite them. I’m wondering now, what is the usage of local
in the outermost scope. I searched the web, but can’t find any info. They don’t seem to be a required syntax of Lua when creating variables, because someVariable = "foo"
seems to work fine in the Roblox Studio command bar, and in scripts too. Can someone bring up a reasonable explanation?