I have a custom module loader that runs fine and does what its supposed to but for some reason is blocking my Players.PlayerAdded connection. I just need it to init the player from my module.
Here is the code. The output right now is 1 but not hello
task.wait()
shared.ModulesLoaded:Wait()
--Service
local Players = game:GetService("Players")
local PlayerModule = shared.Get("Player")
local function OnJoined(Player)
print("hello")
PlayerModule.new(Player)
end
print("1")
Players.PlayerAdded:Connect(OnJoined)
Here is the module loader:
local Signal = require(script.Signal)
shared.ModulesLoaded = Signal.new()
local ModuleLoader = {}
local CachedModules = {}
--Loader Functions
function ModuleLoader.Get(moduleName: string)
return CachedModules[moduleName]
end
function ModuleLoader._Init(modules: {ModuleScript})
for _, module in modules do
local newModule = require(module)
CachedModules[newModule.Name] = newModule
end
end
function ModuleLoader._Start()
for _, module in CachedModules do
if module.Start then
task.spawn(module.Start)
end
end
end
shared.Get = ModuleLoader.Get
return ModuleLoader
NOTES:
- Will print if anything related to the module is taken out of the script.
- When putting the connection in a variable, conn.Connected = true
- Im using Fast Signal Immediate for my custom signals
- Is under another script under server script service. But when placing the the problem script in server script service. still doesnt fix anything