Player Added never firing?

So I dont know why but my script was working fine and I ended the test then tried again and Player added just stops firing at all no matter what. Theres no errors in the script besides my whole entire game breaking because of this.

I even put a simple print (“Hi”) at the start of the player added event and It does not print.
ex:

game.Players.PlayerAdded:Connect(function(plr)
     print("hi")-- nothing prints
end)

this is super frustrating and this issue also happens when i publish the game when this happened and if I joined the game (not in studio but on the website) this issue still happens.\

any fixes?

Is your script located in ReplicatedStorage or ServerStorage? Maybe it’s in a LocalScript?

You are using a server script correct?

The script is located in ServerScriptService. Like I said this happened when I didnt make any changes and was working perfectly fine before.

Is this in studio or the actual game? PlayerAdded may not fire in studio and you will need to loop through each player in the game after connecting the PlayerAdded event.

Like I SAID… this also happened in game but ill try to loop through each player.

Can you take a screenshot of your explorer where the script is located? Also ensure that “All” is checked in your console:

https://i.gyazo.com/7c94e722e69737b42ae20b4810e8ea5c.png

PlayerAdded always fires inside of Studio.

Dude I am very experienced with studio. You dont have to talk to me like I am one of the other newbie devs. And yes the script is in ServerScriptService. I just double checked.

Maybe include screenshots instead of getting angry at us, you came to us for help lol

2 Likes

Sorry I am really pissed off because of this but here:

And the player added event is in the DataStoreMain script (which is not working).

Is it possible the Players service isn’t loaded when the script runs? I’ve only had this issue once but it wasn’t related to your current setup.

Does the PlayerAdded event work inside of other scripts or just that specific one? If it’s just that one, please include the full script as it’s most likely something inside it causing the problem.

Nope. It happens with every Server Script in any Parent Workspace, Replicated Storage, ServerStorage etc. Even with a fresh new Server Script this still happens.

Interesting. It could be because your player is added before the script is actually executed; have you tried this with more than one person so the script has time to load in?

Yeah this is in fact the case but How do i fix this? (I just tested it with a alt)

Here, try this script. I know it’s a bit overkill for something this simple but I get the service rather than indexing it directly, and I added the loop I mentioned earlier.

local Players = game:GetService("Players")

local function PlayerAdded(Player)
	print(Player.Name)
end

Players.PlayerAdded:Connect(PlayerAdded)

for _, Player in pairs(Players:GetPlayers()) do
	PlayerAdded(Player)
end

Thanks dude it worked perfectly :smiley:

Alright, to test which change was the fix I suggest removing the for loop and trying that. If it prints, not using :GetService() was the issue. I honestly don’t know what the cause was though.

I actually already had getservice and removing it didnt do anything :confused:

Alright, then it was because the player loaded before the event was connected. I still recommend using :GetService() when using any service just incase the service isn’t created when you access it.