Help with module script

local module = {}
module.__index = module
local startmain = require(script.SpawnMain)
local Hatsmain = require(script.GetHats)
local SpawnMain = require(script.SpawnHat)
local Datas = require(script.DataStore)
local devpro = require(script.DevProducts)

game.Players.PlayerAdded:Connect(function(plr)
	print("added")
	Datas:Load(plr)
end)

module.Hat = Hatsmain.GetHats()


function module.Start()
	devpro:Start()
	startmain.Start(setmetatable({},module))
end

function module.SpawnHat(id,price)
	SpawnMain.SpawnHat(id,price)
end

function module:AttemptSpawnHat()
	SpawnMain.AttemptSpawn(self.Hat)
end

return module

so at this code i want to make module.hat variable a global variable also i do not want to call the GetHats() function everytime i require the module i want the module to load the hat var and do not load it again

I think I can help, but im a little confused what you’re asking for. Can I have more details about what you’re trying to do

i want this module to get the hats without calling the hats() function

local devp = {}

local devProducts = {
	[1563124399] = 20
}

local spawnhats = require(script.Parent.SpawnHat)

local devs = setmetatable({}, devProducts)

function devProducts:__index(DevProductsid)
	local meta = getmetatable(self)
	local price = meta[DevProductsid]
	
	for i = 1, price do
		spawnhats:AttemptSpawn()
	end
end

function devp:Start()
	local hi = devs[1563124399]

end

return devp

the attempt spawn needs the hats megatable for spawning a random hat