Humanoid.Died Function isn't working properly?

This is a local script inside a folder in StarterGui. It dosen’t print anything and it dosen’t look like the Died Function even got fired.

game.Players.LocalPlayer.CharacterAdded:Connect(function(Char)
	Char.Humanoid.Died:Connect(function()
		print("Played Died.")

		wait(1)

		local Character = game.Players.LocalPlayer.EquippedUnit.Value

		game.ReplicatedStorage.InventoryFired:FireServer(Character)
	end)
end)

I’m guessing you want someone to be killed but by what??

There is various weapons inside the game, if the players die they respawn. But I also have costumes and such for the avatar, so I’m trying to find a way so that the Player will automatically respawn with the costume.

The Died event is fired when the humanoid’s health value is set to 0.

Make sure the when the player “dies” it is actually killing them and not just respawning them.

I tried to test the script by reseting myself through the Roblox Menu, does that not work?

That works. I’m going to look more into it. Give me a minute to run some tests.

I noticed while debugging that when I have the LocalScript in StarterGui, the Humanoid.Died event never fires…

Try moving your script to StarterPlayerScripts and also adding a WaitForChild on the humanoid.

Because the event
game.Players.LocalPlayer.CharacterAdded
will fired only once the character got add in the game
try using
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
char.Humanoid.Died:Connect(function() – then continue with your code
Didn’t test it yet, but hope it would work!

I noticed that the code he used works perfectly when placed in StarterPlayerScripts, but not StarterGui.

I had place it in StarterCharacterScripts and that didn’t work either lol

StarterPlayerScripts, not Character

*wrong reply recipient

wouldnt you just want to bypass the character added, and instead just get the local player’s character and start the listening function?

I was telling you what I did before, sorry for the confusion. I’m testing it out rn in StarterPlayerScripts.

Yeah I guess either way would work. We would need to change the code a bit if we wanted to do that (which isn’t a problem)

One minor issue is that he wants things to wait a certain amount of time after dying, which might not work because the character might be destroyed by then.

Then it would only work once, idk why. I think the character becomes nil or something.

Is it work? that’s weird. I using my code in starter gui folder and it also work even not in playerstarterscript

Did you add the WaitForChild? I tested it myself and it seemed to work perfectly.

It works now, thank you. I hate the chars requirement.

it will become nil since the script loads instantaneous regardless of whether the char is loaded or not probably

Maybe this is a bug, not sure. I’m not a regular yet so I can’t post in bug reports.

Ignore my 80s music