Using modules with UI tips

local statsHandler = {}

local selected = 'Knight'

local frame = script.Parent

local class = frame:WaitForChild('Class')

local armour = frame:WaitForChild('Armour')
local weapon = frame:WaitForChild('Weapon')

local select = frame:WaitForChild('Select')
local previous = frame:WaitForChild('Previous')
local next = frame:WaitForChild('Next')

	if selected ~= 'Knight' then
		selected = 'Knight'
		previous.ImageColor3 = Color3.fromRGB(25, 25, 25)
		next.ImageColor3 = Color3.fromRGB(85, 170, 255)

	if selected ~= 'Archer' then
		selected = 'Archer'
		next.ImageColor3 = Color3.fromRGB(25, 25, 25)
		previous.ImageColor3 = Color3.fromRGB(85, 170, 255)

return statsHandler

Been trying to stick to 1 server/1 local script and trying to use module scripts around the place. Would this be the way to go around it in one way? Having a module within each seperate frame (for example a shop module to handle all the shop ui elements, etc.) or this example which handles a class UI. Any advice/tips would be great :smiley:


I would say there aren’t any problems with it. I’ve done similar – although I prefer just doing this at the moment:

There’s no real right way.

As a suggestion, it may be easier to simply return true instead of doing stuff with statsHandler as it’s an unnecessary use of resources and just uses up lines. The module doesn’t use it all, so there’s no point in making it.


returning true where?


Right at the end of the module. There’s no need to return anything from it since you aren’t doing anything with the table you are currently returning – however you must return at least one value, so true is a good option.