So, i am working on a game involving knives. Whenever i "kill" someone, they don't die, but they go to negative health. It's really frustrating. I even tried making a script that breaks joints when you reach 0 health, but that didn't work. Any help is appreciated. Thanks!
How come players in my game don't die when they reach 0 health?
1 answer
Your problem could be in several factors.
You don't check the player's health correctly
You don't subtract the player's health correctly
How do you check if the player's health is less that 0? If your using
if humanoid.Health == 0 then whatever end
then you are doing it wrong. You need
if humanoid.Health <= 0 then whatever end
However, I doupt that this is your problem. Now, I bet you damage the players via the following method:
humanoid.Health = humanoid.Health - 20 (or whatever the damage is) end
While this is not wrong, it is also possible to do it via the :TakeDamage() function. your script would look like this:
local damage = 20 --How much damage the knife does
humanoid:TakeDamage(damage)
Lastly, if all else fails, I have only one idea of what to do. Check it the player has <= 0 health, and then call the :LoadCharacter() function on their player (not character). Your script would look like this: (LocalScript inside StarterPlayerScripts)
local player = game.Players.LocalPlayer
while true do wait(0.1)
if player.Character ~= nil then
local humanoid = player.Character:FindFirstChild('Humanoid')
if humanoid ~= nil then
if humanoid.Health <= 0 then
humanoid:TakeDamage(math.huge()) --Makes them take infinite damage. (Might not work in your case)
player:LoadCharacter() --Forces them to respawn
end
end
end
end
Accept if helped thx
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
This sounds like you are using FE and have applied the damage in a local script which will not replicate to the server. If this is the case you need to take the damage on the server side so that the change will replicate.
It's probably because of FE like he said^ but you could use :BreakJoints() as well