TakeDamage Allows Negative Player Health

Issue Type: Other
Impact: Low
Frequency: Constantly
Date First Experienced:
Date Last Experienced:

Reproduction Steps:
Put the following code into a LocalScript:

local player = game.Players.LocalPlayer
while wait(1) do
	pcall(function()
		player.Character.Humanoid:TakeDamage(1000)
	end)
end

And then test.

Expected Behavior:
The player’s health should get locked to 0, just like normal subtraction.

Actual Behavior:
The player’s health will drop far below 0 (though there’s a 1-second check that will reset it.)

Workaround:
Just subtract health directly instead of using TakeDamage.

8 Likes

Isn’t the issue using a LocalScript for this? IIRC what actually kills the player when setting the health locally is the joints breaking for a fraction of a second, not the health itself. I see the bar being glitched, but is the health actually going negative? I feel like it’s a server vs client discrepancy.

3 Likes

Interestingly enough, using a server script actually does fix the issue. However, the client has control over the player’s health, so the fact that this happens with a LocalScript should still be fixed.

3 Likes

I ran your script and I saw the red health bar extend far backwards for a brief moment every second. This makes no sense that it happens. I also ran the following in between respawns.

local humanoid = game.Players.LocalPlayer.Character.Humanoid
humanoid:GetPropertyChangedSignal("Health"):Connect(function()
    print(humanoid.Health)
end)

And yes, the health is negative for a few frames at a time.

image

I do have a question about this:

Can you help me understand how the client has control over the local player’s character health? In my testing, the only change I’m able to replicate to the server is setting the health to zero, which produces the same result as clicking “Reset Character” in the menu. Any value above zero that I’ve tried doesn’t replicate.

1 Like

I mentioned this, that’s why it’s a loop:

I don’t know the exact details, but the client being able to kill the player is intended behavior, so this issue that can occur while attempting to kill the player should be resolved.

1 Like

Thanks for the report! We’ve filed a ticket to our internal database and we’ll follow up when we have an update for you.

4 Likes

Sorry for bumping but I really need this fix so it could work on my game. Have this been fixed? You didn’t really give us an update.

Instead of bumping an old thread you can just try it yourself to see if it is fixed. From what I’ve seen its been fixed.

I did but it’s still not fixed, well atleast on a model including a:
Humanoid, Part (named Head obviously)

(Edit: I found a fix from my problem nevermind!)