--[[
    Server Init
]]


local RunServ = game:GetService("RunService")
local ServStore = game:GetService("ServerStorage")

local ServerScripts = ServStore.Modules:GetChildren()

local modules, priority = {}, {}
for _, module: ModuleScript in ipairs(ServerScripts) do
	if module:IsA("ModuleScript") and not module.Name:find("IGNORE") then
		local mod = require(module)
		priority[mod.InitPriority] = mod
		modules[module.Name] = mod
	end
end

local function call_loop(dt: number)
	for _, module in modules do
		module:Loop(dt)
	end
end

for _, module in ipairs(priority) do
	module:Init()
end

RunServ.Heartbeat:Connect(call_loop)
