Script doesn't detect that Dummy is dead

The problem is that
the script doesn’t detect that the dummy is dead
i think the problem is that you one hit the dummy
I show you the problem with a video and the code is simple Dummy.Humanoid.Died:Connect(function()
this is what i DON’T want to have

if the dummy dies then its respawning and give you xp but it need to detect the dummy died and this doesn’t work
this is what i want but with one hit working too

the humanoid health is always going in to negative im using :TakeDamage() to do the damage
and no you can’t use HealthChanged because the script gives a player exp
here the script:
local Dummy = script.Parent
	for _,v in pairs(Dummy.Humanoid:GetChildren()) do
		if v.Name ~= "Animator" then
			if game.Players:FindFirstChild(v.Name).Stats.Level.Value < 1500 then
				local player = game.Players:FindFirstChild(v.Name)
				if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 7917326) then
					game.Players:FindFirstChild(v.Name).Stats.EXP.Value = game.Players:FindFirstChild(v.Name).Stats.EXP.Value + 10
					game.Players:FindFirstChild(v.Name).Stats.EXP.Value = game.Players:FindFirstChild(v.Name).Stats.EXP.Value + 5

its in the dummy and its a normal script

to damage the dummys im using :TakeDamage()

Would it be possible to use HealthChanged and check that the Health is 0?

    if newHealth == 0 then
        --// They died

Just pointing out @return_end1’s solution, I’ll just modify it a little bit since the health changed to a negative value after the one hit.

You could use the HealthChanged event, but check that Health is equal or less than 0, not just when it’s 0. So you’d write something like the following.

    if newHealth <= 0 then
        --// They died
1 Like

A Humanoid’s Health can’t go lower than 0, it’s locked between 0 and MaxHealth as stated by the api-reference:

Health is a property that represents the current health of the Humanoid . The value is restricted to the range [0, Humanoid.MaxHealth ]. If the Humanoid is dead, Health is continually set to 0.

Therefore, there’d be no need for if it’s lower than or equal to 0.

Problem looks like it has more to do with how you’re distributing health changes to the Humanoid from your tools. I’m just noting how the One Handed Katana unexpectedly sets the Humanoid’s health to a negative value.

Lack of code really hurts in terms of trying to assist you here. Are you able to provide the snippits in use for damaging Humanoids both from your punch or katana tools?

I doesn’t find any fix for that

Using this, you could use a “KillJoints()” command inside, and then refresh by “Destroy()”, and have a “Clone()” copy ready before the function, in ReplicatedStorage; just to give you an idea of what to script, as I do not know much of your variables.

The problem is here when i do this then you can hit the dummy and get more xp because the dummy thinks the player killed the dummy again and get more xp

When the dummy dies then a player get xp because i made a BoolValue with the name of the player and when the dummy dies the player get exp but with .Died:Connect(function() the dummy can only die once
and then have to respawn with .Health <= 0 the script thinks the dummy died again

Add a clone in ReplicatedStorage; call that clone in the script, after it detects the dummy has less than 0 HP and removes it.

if you do .Health <= 0 then it glitches out and give you much more xp than it should be
but when i do .Died:Connect(function() then it doesn’t detect that it is dead