Is it 'OK' to use modules just for organization?

Title is self explanatory. My modules just act like a local script and the only reason I’m using them is for organization. I could have just went with local scripts but I want to know if it’s fine because I don’t want to rewrite all the scripts.

The modules are placed inside local scripts from where I call of them. Each module script acts like a local script for handling different UI’S.

I don’t use the modules for requiring functions or what you would normally do with a module. They act like a local scripts.

image

Some of the modules:

Buttons Handler Module

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

local clickSound = ReplicatedStorage.Audio.ClickSound

local shopUI = playerGui:WaitForChild("ShopUI")
local sideUI = playerGui:WaitForChild("SideUI")

local mainFrame = shopUI:WaitForChild("Frame")

local DEFAULT_COLOR = Color3.fromRGB(76, 83, 85)

local function defaultColor()
	local shop = sideUI.Shop
	local upgrade = sideUI.Shop
	
	shop.ImageColor3 = DEFAULT_COLOR
	upgrade.ImageColor3 = DEFAULT_COLOR
end


local button = mainFrame:FindFirstChild("CloseFrame"):FindFirstChildWhichIsA("TextButton")
	
button.Activated:Connect(function()
	clickSound:Play()
	shopUI.Enabled = false
	defaultColor()
end)

return defaultColor

Categories Handler Module

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

local clickSound = ReplicatedStorage.Audio.ClickSound

local shopUI = playerGui:WaitForChild("ShopUI")

local mainFrame = shopUI:WaitForChild("Frame")

local pointsFrame = mainFrame.Points.PointsFrame
local itemsFrame = mainFrame.Items.ItemsFrame
local passesFrame = mainFrame.Passes.GamepassFrame
local viewFrames = mainFrame.ViewFrames

local COLOR_DEFAULT = Color3.fromRGB(74, 83, 85)
local COLOR_CHANGE = Color3.fromRGB(115, 188, 214)

local categories = mainFrame.Categories.ButtonBar:GetChildren()

local function hideFrames()	
	for _, viewFrames in ipairs(viewFrames:GetChildren()) do
		viewFrames.Visible = false
	end
	itemsFrame.Visible = false
 	pointsFrame.Visible = false
	passesFrame.Visible = false
end

local function viewFrames(frame)
	hideFrames()
	frame.Visible = true
end

local function changeColorDefault()
	for _, category in ipairs(categories) do
		category.ImageColor3 = COLOR_DEFAULT
	end
end

local function changeColor(frame)
	changeColorDefault()
	frame.ImageColor3 = COLOR_CHANGE
end

for _, category in ipairs(categories) do
	
	local button = category:FindFirstChildWhichIsA("TextButton")
	
	button.Activated:Connect(function()
		
    if button.Name == "Items" then
			clickSound:Play()
			changeColor(category)
	        viewFrames(itemsFrame)
		
	elseif button.Name == "Passes" then
			clickSound:Play()
			changeColor(category)
	        viewFrames(passesFrame)
		
	elseif button.Name == "Points" then
			clickSound:Play()
			changeColor(category)
	        viewFrames(pointsFrame)
		 end
	end)
end

return hideFrames
1 Like

In general, organization is very important when it comes to programming.

Honestly, that wasn’t really my point here sorry.

Real point was if I can use modules just for organization and return a function for UI Handling only?

I don’t really see anything wrong here. This is kind of the intended purpose for modules in Roblox.

2 Likes

I see nothing wrong with doing so.