Hi guys.

So I'm having this terribly annoying issue and I can't find a fix.

When a player dies, I want the script to print a simple string "Died!". However, when the player dies the script just seems to not care and looks the other way. No prints, no errors, nothing!

The funny thing however; when I manually set my Health to 0 in the Humanoid (Workspace > PlayerName > Humanoid), the function DOES fire.

I'm using a server-sided script in ServerScriptService, with the following code; (Has been shortened for simple reading, I made sure no parts are missing.


function died()
		print("Died!")
	end	

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

	player.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function()
			died()
		end)
	end)

end)

Any ideas??

6 comments

0

Humanoid.HealthChanged:Connect(function(Health) if Health == 0 then --code end end)? Might not be the best way, but have you tried that?

0

It works on reset, but executes around 5 times during the death-phase. Any ideas?

0

Have you tried using player.Character... to see what occurs?

0

Yep. That's when the script executed 5 times. Normally I would ignore it, but sadly the script is ment to drop certain items upon death later on, which this issue would ruin.

0

When does this not work exactly? I'm using your exact script in studio and it works fine. If I set my health to 0, remove my head or reset, "Died!" prints just fine.

0

When using my script above the Died print doesn't show up. When using the suggested function I have to reset once without seeing the print, but resetting a second time does print the Died! string..