Hello, I’m not sure if this is the right category to put this question in, but I have been analyzing a few Scripts I’ve seen developers using, and I keep seeing a pattern where people create ModuleScripts which are only used by one Script. I thought this was quite odd, so I tried researching about this, but everywhere I’ve searched has just said that ModuleScripts are only used when more than one Script requires them, meaning that the ModuleScripts they wrote wouldn’t make sense.
Normally, these ModuleScripts will contain things a Server or Client sided Script can do, and I’d just like to know if it is correct to implement them in a game, or if it is best to just use a normal Script for them (I’m mostly asking this because these ModuleScripts could perhaps be used to organize the code they are writing into more understandable and manageable pieces, but I feel as if that wouldn’t make that much sense since they would only be used for 1 Script).
Below you can find an example of one of these ModuleScripts I’ve seen (do note that this one is only used by one Script, which calls it to either detect if the Player left or entered a cave).
local module = {}
local lightning = game:GetService("Lighting")
function module.detectPlrAction(plrAction)
if plrAction == "entering" then
local colorCorrection = Instance.new("ColorCorrectionEffect")
colorCorrection.Contrast = 0.75
colorCorrection.TintColor = Color3.fromRGB(212, 212, 212)
colorCorrection.Name = "CaveColorCorrection"
colorCorrection.Parent = lightning
elseif plrAction == "leaving" then
if lightning:FindFirstChild("CaveColorCorrection") then
game:GetService("Debris"):AddItem(lightning.CaveColorCorrection, 0)
else
warn("CaveColorCorrection not found")
end
end
end
return module