Players.PlayerAdded suddenly just stopped working?

Hello. I have a server script here, and part of it has event when a player joined. It was all working and now it just suddenly broke. I decided to try print something when someone joins, nothing happened. Code:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(user)
   print("Test")
end)

I get no error, no nothing. Really weird. Any help would be appreciated.

Previous topics covered that.

When do you define the connection? If there’s some yielding beforehand then it might not fire for the first player.

Double check you’re looking at the server log not the client log as well.

Unusual, Players.PlayerAdded always worked for me before, do I have to do that?

If you want to catch the very minimal chance of that happening, that is. Unless you are not reviewing the logs correctly(if you were in a real game), as previously mentioned.

Looked at both logs, here is the code I have.

local BanModule = require(game.ServerScriptService.Modules.BanModule)
local DiscordModule = require(game.ServerScriptService.Modules.DiscordModule)
local ConfigModule = require(game.ServerScriptService.Modules.ConfigModule)
local Players = game:GetService("Players")
local BanEvent = game.ReplicatedStorage.Events.BanUser
local CheckEvent = game.ReplicatedStorage.Events.CheckUser
local UnbanEvent = game.ReplicatedStorage.Events.UnbanUser
local GroupId = ConfigModule.GroupId
local MinRank = ConfigModule.MinRank

Players.PlayerAdded:Connect(function(user)
   print("Test")
end)

All the other variables are for other things, but would any of these be doing anything?

I just find it really weird, because it happened all of the sudden with no edits.

Now when you mention that, the other modules might have caused some yielding before the connection was added. Can you check if removing the modules actually changes the output?

Did that, and it prints. Something in the variables is holding it up but I’m not sure what it would be. I’ll try remove some un-needed modules and see what happens

Every time you use require(), the thread yields until the modules return something. Check the modules to see if the thread is actually being yielded by anything, from possible pcalls to wait() or equivalents.

If you find any of those, the architecture is flawed for PlayerAdded connections only, thus you have to do the catch-all scenario from my first post above.

Alternatively, you can rewrite the architecture by pushing them into coroutines, if that does not affect the output.

Think I’ve found one module doing something, I’ll check over the module and get back to you. Thanks for the help!

It’s totally okay to have modules that yield if they are needed. You just have to be aware and counter it using a similar method in the post Operatik linked to. Especially if the module is needed as part of your PlayerAdded handler.

Otherwise, you could move the require statement after the PlayerAdded connection.