CharacterAdded event not firing

After scripting 4 year I’m dissapointed I’m having to make a thread of an issue that seems so simple, but I really can’t figure it out… The title is exactly the issue, the event wont fire.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		print("character added")
	end)
end)

The statement above will not print… I have no clue why.

1 Like

Where is the script located? It is working fine for me when its in ServerScriptService

Heya, if this is a local script it will not work.
With some more context or information I can help you write something better?

Otherwise if you can do what you intend on doing on the server, make it as a script not a local script.

if it’s a local script, it won’t work because the player has already appeared before the script starts (client loaded, then we play client code, not the other way around). So the problem isn’t that your CHaracterAdded isn’t working, but that your PlayerAdded isn’t working

1 Like

This is in a server script (minimum chars)

Ok, just did some more testing and it works but not on initial launch I guess?? I have to actually reset my character for it to run, which leads me to believe the character is loading before the event connects. That doesnt make sense though because how is the character loading faster than the script?

Maybe archivable or enabled is set to false?

On what? minimumcharsssssssss

Do you have deferred mode enabled?

I remember having this issue once aswell and it was because of the order I was calling things so I moved the CharacterAdded listener above the other functions. Can you show us the full script?

Simply

local Players = game:GetService("Players")

function playerCharacterAdded(player, character)
        if not character then
                return
        end
       print(player, character)
       -- do stuff
end

function playerAdded(player)
        if player.Character then
                task.spawn(playerCharacterAdded, player, player.Character)
        end
        player.CharacterAdded:Connect(function(character)
                playerCharacterAdded(player, character)
        end)
end

for _, v in Players:GetPlayers() do
       task.spawn(playerAdded, v)
end

Players.PlayerAdded:Connect(playerAdded)
1 Like

Easy fix, although not a very elegant solution

game.Players.PlayerAdded:Connect(function(player)
	task.wait(1)
	player.CharacterAdded:Connect(function(char)
		print("character added")
	end)
	player:LoadCharacter()
end)
local Players = game:GetService("Players")


Players.PlayerAdded:Connect(function(player:Player):()
	local function CharAdded(char:Model):()
		print(player,"character added:",char)
	end
	player.CharacterAdded:Connect(CharAdded)
	if player.Character~=nil then
		CharAdded(player.Character::Model)
	end
end)

This is the solution. The problem with your original script was that the player who started the server was already added before your PlayerAdded connection was executed by the server.

Yeah, I just realised that you meant your server script by minimumcharsssssssss lol, I’m guessing it didnt work. Looking at other replies, what if you added a task.wait() at the start of the script? to give any unfinished processes time to complete before the event

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.