I’ve seen different styles when it comes to defining properties inside a Lua table (like a module or manager) in Roblox development, and I’m curious what other devs prefer and why.
Option 1 – Define everything inside the table upfront:
local ZombieManager = {
ActiveZombies = {}
}
return ZombieManager
Option 2 – Create the table first, then add properties:
local ZombieManager = {}
ZombieManager.ActiveZombies = {}
return ZombieManager
Both seem to work the same in practice, but I’m wondering:
Is there a best practice in the Roblox Lua community for readability, organization, or performance?
Are there scenarios where one is clearly better than the other?
Would love to hear your thoughts especially from anyone working on modular systems or large-scale games!
Probably just up to preference.
Sometimes I prefer the former as it makes the structure clearer, or if structure is not that important and I’m just sectioning off something like a configuration table, I do something like this: