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!
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