Only plugins are able to modify the source code of ModuleScripts, LocalScripts and Scripts
From what I can understand, creating a base class that all hats inherit from (like how Parts inherit from the BasePart class), then adjusting the configuration according to the type of hat would work best in a case like yours
I recommend you familiarize yourself with object-oriented programming and metatables:
@lilsquish08 Here’s an example of how the module will need to look like:
local BaseHat = {
Color = Color3.new(0, 0, 0),
Name = "Hat",
Price = 100
}
BaseHat.__index = BaseHat
local Hat = {
new = function()
return setmetatable({}, BaseHat)
end
}
return Hat
And this is an example of how to create and configure a new hat using the module (tested using a Script in ServerScriptService):
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Hat = require(ReplicatedStorage.Hat)
local topHat = Hat.new()
topHat.Color = Color3.new(1, 1, 1)
topHat.Name = "Top Hat"
topHat.Price = 300
print(topHat)