Humanoid.Died signal only firing in the field, not in Studio

I have a test character with a Humanoid in it and a script that sets its Died connection and then later sets its Health to 0. It works as I would expect it to when I Play it from the website (⚔️Castleheart Working ⚔️ - Roblox) but not locally in Studio, no matter whether I Play, Run, or Start a client-server test.

This is the script -

print(“Hello world!”)

function funkyfunky()
error(“Happy days!! Or are they?” )
end

local testConnection = script.Parent.Humanoid.Died:connect( funkyfunky )
if testConnection.Connected then
warn(“testConnection connected”)
else
error(“testConnection NOT connected”)
end

wait(10)

script.Parent.Humanoid.Health = -100

wait(1000)

I would expect this script to error out with the message “Happy days!! Or are they?” and it does when I Play it from the website, but not from Studio.

I started noticing this bug just yesterday (4/6/2017), but that doesn’t necessarily mean anything - it was only then that I started working with the Died signal.

For me, it’s 100% reproducible.

Using your code, I haven’t been able to replicate the issue, could you upload the place file?

Putting this in a Script in Workspace works fine for me in Studio Run mode / Test player:

game.Players.PlayerAdded:connect(
	function(plr)
		plr.CharacterAdded:connect(
			function(model)
				
				model:WaitForChild("Humanoid").Died:connect(
					function()
						error("Event has been fired!")
					end
				)
				
				wait(5)
				
				model.Humanoid.Health = -100
				
			end
		)
	end
)

So I can also not reproduce this issue.

Some questions:

  • Are you sure you’re checking the right output window (if you’re using Test Server + Test Player)? It’s a dumb question but it has to be asked. :slight_smile:
  • Are you on Windows or Mac?
1 Like

Here is the place file

HumanoidDiedTest.rbxl (16.2 KB)

Your player-killing script works for me too. But I’m trying to kill an NPC.

  • Are you sure you’re checking the right output window (if you’re using Test Server + Test Player)? It’s a dumb question but it has to be asked. :slight_smile:

99% sure. On the Server, F9

  • Are you on Windows or Mac?

Windows

I could show you via skype or upload a video if you’d like proof. :slight_smile:

Ah, your dummy is missing a HumanoidRootPart (HRP). The Humanoid won’t actually die when you set the health to -100 unless it is inside a properly set up character. (you can tell the NPC is not dying, because it doesn’t break into pieces when you set the health to that)

Try this file, I added the HRP for you in the character:
HumanoidDiedTestFixed.rbxl (16.3 KB)

It’s usually the same size as the torso part, and also welded to the torso, where the HRP is the root part of the weld. You should be able to copy paste that basic HRP in the file into every NPC you have, it should work that way.

It’s not obvious that you have to do this though, the documentation doesn’t mention this at all.

1 Like