Is it safe to use Module Script to get a lot of Instances

I have a module script that has a lot of values,

local module = {}
local RepStorage = game.ReplicatedStorage
module.Neighborhood = workspace:WaitForChild("Neighborhood", 10)

module.ToolsFolder = RepStorage:WaitForChild("ToolsFolder")
module.NoteTool = module.ToolsFolder:WaitForChild("Note")
module.SpeedCoilTool = module.ToolsFolder:WaitForChild("Speed Coil")
module.PlayerChestKey = module.ToolsFolder:WaitForChild("PlayerChestKey")
module.Toy_Crown = module.ToolsFolder:WaitForChild("Toy Crown")
module.ShovelTool = module.ToolsFolder:WaitForChild("Shovel")
module.MansionKey = module.ToolsFolder:WaitForChild("Mansion's Key")
module.CupTool = module.ToolsFolder:WaitForChild("Cup")
module.CupWaterTool = module.ToolsFolder:WaitForChild("Cup of Water")

module.RemEvents = RepStorage:WaitForChild("RemoteEvents")
module.EquipNewTools = module.RemEvents:WaitForChild("EquipNewTools")
module.ChangeTools = module.RemEvents:WaitForChild("ChangeTools")
module.DestroyGui = module.RemEvents:WaitForChild("DestroyGui")
module.GetPlayerItems = module.RemEvents:WaitForChild("GetPlayerItems")
module.DestroyMansionObj = module.RemEvents:WaitForChild("DestroyMansionObj")
module.TypeGuiText = module.RemEvents:WaitForChild("TypeGuiText")

module.GuiFolder = RepStorage:WaitForChild("GuiFolder")
module.EquipItemsGui = module.GuiFolder:WaitForChild("EquipItemsGui")
module.ReceivedItemGui = module.GuiFolder:WaitForChild("ReceivedItemGui")
module.MessageGui = module.GuiFolder:WaitForChild("MessageGui", 10)
module.PizzaManGui = module.GuiFolder:WaitForChild("PizzaManGui", 10)
-- there's a lot more values, just keeping it short
return module

And was wondering if it’s bad to do something like this, such as it affecting performance or if exploiters can do something with this. If nothing is said I’m gonna assume it’s safe :d


Not really answering the question but if your goal is to just have a module scripts with instance references with the same name as their ingame name you could just do this.
Granted, you lose out on autocomplete for the key but functionally it should be the same.


As for it’s safety, it depends on the scripts location and how you use it. if the module script is inside server-script service/server-storage it cannot be accessed by the client and is inaccessible by exploiters.

It is fine to do it. I also do the same thing. But it really doesn’t look clean.
You can make a loop INSIDE the module script. Also, making tables inside the module script will make it even more cleaner. For example: = {--[[something goes here...]]}
-- AND, if you want:
for i, tool in pairs(game.ReplicatedStorage:WaitForChild("ToolsFolder")) do[tool.Name] = tool

I wish you luck with your game!

Having this hidden doesn’t really enhance security significantly; it’s more like a friendlier catalog of things. Exploiters can still view the things they have access to, regardless.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.