Player.CharacterAdded() event not working?

Hello, my problem here is pretty basic: the CharacterAdded event just doesn’t fire.
This is my script right here:

game:GetService("Players").PlayerAdded:Connect(function(plr)
       --player stuff here
       plr.CharacterAdded:Connect(function(char)
              print("Character added.")
              --character stuff here
       end)
end)

This makes my game break, as in the character I put a lot of essential things, like stats, the player’s custom avatar, etc…
As you can see “Character added” isn’t being printed, and I’m being spammed of errors from all the GUIs that ask for the player’s stats located in the character:
Capture

The problem might be that I’m using the DataStore2 module (even tho I already used and never got problems…)? Cause there’s nothing in my script BEFORE the CharacterAdded() event that ask for the character or stuff like that, just values being created and put into the player, and getting the player’s data with DSS2.

4 Likes

Sometimes in studio the player will load before the actual event can connect, you can fix this by setting up a custom respawn system:

Firstly set the property Players → Players -->> CharacterAutoLoads = false

Next you want to setup the code to spawn players for you, here is an example I wrote:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
	
	Player.CharacterAdded:Connect(function(Character)
		
		
		Character.Humanoid.Died:Connect(function()
			wait(3)
			Player:LoadCharacter()
		end)
	end)
	
	Player:LoadCharacter()
	
end)
38 Likes

Thank you! Omg I was actually frustrated, I wasn’t understanding what was happening at all. Didn’t know about this feature that you can use to load the character manually… Well thx for making me know this, I think I’ll use it everytime now so I won’t encounter any problem when loading the character. :smile:

7 Likes