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.
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.
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)
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.