I am trying to make sure that the hit player only gets downed (2HP) when reaching below 2HP, but they still die regardless.
function Check(Health)
if Main.Damage <= Health then
return Main.Damage -- 45
end
return 0 -- Random check
end
if Victim.Health <= Main.Damage then
Victim.Health = 2
else
Victim:TakeDamage(Check(Victim.Health))
end
Once a Humanoid’s Health reaches 0, it will automatically die, no exceptions.
There is no “reviving” here; you can’t set the Health back to 1 or any number greater than 0.
It won’t make it “alive” again.
Just connect the event to begin with, and every time the character respawns it will automatically do it
A script in StarterCharacterScripts with this would do the trick:
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.HealthChanged:Connect(function()
if Humanoid.Health < 2 then
Humanoid.Health = 2
end
end)
function Check(Health)
if Main.Damage <= Health then
return Main.Damage -- 45
end
return 0 -- Random check
end
if Victim.Health <= Main.Damage then
Victim:TakeDamage(Victim.Health - 2)
else
Victim:TakeDamage(Check(Victim.Health))
end
Best way to do this is to just check every time when you are trying to take health away that it stays above 0 before you actually subtract. Puzzled made a very great example on doing this.