CharacterAdded/Humanoid.Died not working

As stated in the title, the CharacterAdded nor the Humanoid.Died Events are firing. Its a Script inside ServerScriptService:

game.Players.PlayerAdded:Connect(function(plr)
	--OTHER CODE FOR DATASAVING
	
	plr.CharacterAdded:Connect(function(char)
		print("Now") --Thats not printing
	end)
end)
1 Like

Probably because your datasaving code is taking too long.

Try putting the characterAdded event at the top.

Like this:

local Players = game:GetService("Players");

function Add(Player)
	Player.CharacterAdded:Connect(function(Char)
		print(Char.Name)
	end)
	
	--Other code
end

Players.PlayerAdded:Connect(Add);

you can try to use this:

game.Players.PlayerAdded:Connect(function(plr)
	spawn(function()
              repeat wait() until plr.Character ~= nil
              print("Now")
        end)

	--OTHER CODE FOR DATASAVING
end)
1 Like

sometimes the character gets created before the script has a chance to do the characteradded function. I would suggest making a function for your character added & humanoid died functions and call them twice something like this

local function HumanoidDied(char)
      -- Humanoid Died Stuff
end

local function CharacterAdded(char)
      -- Character Added Stuff
      HumanoidDied(char)
end

game.Players.PlayerAdded:Connect(function(plr)
        local char = plr.Character or plr.CharacterAdded:Wait()
        CharacterAdded(char)
	
	plr.CharacterAdded:Connect(CharacterAdded)
end)

Why so many terrible solutions?

local Players = game:GetService("Players")

local function onCharacterAdded(character: Model)
    ...
end

Players.PlayerAdded:Connect(function(player)
    ...

    if player.Character then
        onCharacterAdded(player.Character)
    end

    player.CharacterAdded:Connect(onCharacterAdded)
end)

bro thats legit just mine but without the humanoid died stuff that he was asking for

stupid question: who is the parent of the script?

For everyone here:
Im not trying to get the Character when he joins, I only want to detect when he dies

Still ServerScriptService as in Description

Take one of the scripts that were posted here (I would recommend PhoenixCausesOof’s script)
And then just put a Humanoid.Died event in the CharacterAdded function

My mistake, the event itsself couldnt never reached. There was a mistake with WaitForChild…

1 Like
game.Players.CharacterAutoLoads = false;
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char:WaitForChild("Humanoid").Died:Connect(function()
            print("Humanoid died");
            task.wait(game.Players.RespawnTime);
            plr:LoadCharacter();
        end);
	end)
    --Your data saving code
    plr:LoadCharacter()
end)

CharacterAdded has always had an issue where many times it won’t fire for whatever reason, unless you load the character manually. This basically disables the automatic loading of the character at the start of the game and when it dies, and instead does it manually assuring the event will fire. I’ve had this issue in the past and this solution has always worked

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