Depends how many instances you have.
If you typed them all out in your script, if there’s so many you might end up hitting the local variable limit, then yes.
If you typed them all out, and it made your code look messy, then yes.
But, a long table indexer is annoying to read through too, and may not be the best on memory compared to one table index (yes, ik its only a microoptimisation)
So, what I would suggest is grouping related instances and any functions to manipulate them into one table, as well as other related data, and have many tables of that. A bit like namespaces in other languages. It’ll keep them all organised and look much nicer while not being as harsh on memory (again, microoptimisation)
You can define them all in your module and require it, but modules have to return exactly one value.
So, you can do something like this:
--module
local instances1 = {
["SomeInstance"] = workspace:FindFirstChild("SomeInstance"),
["RandomFunction"] = function() end,
["OtherData"] = 1
}
local instances2 = {
["SomeInstance2"] = workspace:FindFirstChild("SomeOtherInstance"),
["ADifferentFunction"] = function() end,
["OtherData"] = "hi"
}
return {instances1, instances2}
--script
local instances1, instances2 = table.unpack(require(--[[path to module]]))
--etc.