There won’t be a difference in where you place the local variables.
A Module Script has to return something, it doesn’t however have to return everything. In most cases it is the Module Script table that is returned.
local ModuleName = {}
return ModuleName
Anything added to that table will be returned by the require in other scripts.
local ModuleName = {}
ModuleName.SomeVariable = "Some Value"
ModuleName.SomeTable = {}
return ModuleName
So in some other script somewhere,
local ModuleName = require(PathTo.ModuleName)
At this point, you can access whatever is returned from the Module Script, which consequentially is pointed to by the variable above.
local ModuleName = require(PathTo.ModuleName)
print(ModuleName.SomeVariable) -- prints "Some Value"
Because local variables are not included directly in the table, they don’t get the same privilege. They are considered local to the Module Script itself. However, there are ways to “set” or “get” those local variables from the outside source requiring it.
local ThisVariableIsAbove = true
local ModuleName = {}
local VariableNotInModuleNameTable = "This is some text"
function ModuleName.SetText(text)
VariableNotInModuleNameTable = text
end
function ModuleName.GetText(text)
return VariableNotInModuleNameTable
end
function ModuleName.IsVariableAbove()
return ThisVariableIsAbove
end
return ModuleName
Now that you have included these two functions as part of the Module Scripts table, you can do the following in another script.
local ModuleName = require(PathTo.ModuleName)
print (ModuleName.GetText()) -- prints This is some text
ModuleName.SetText("This is some set text")
print(ModuleName.GetText()) -- prints This is some set text
print(ModuleName.IsVariableAbove()) -- prints true
Hopefully that helps a bit with understanding the basic powers of Module Scripting with variables.