Huge Damage leaving HP at a set value

I can’t think of a way of a 100 health dummy taking 900 damage and left with 50 health then it will die.

I tried using humanoid properties but none of them are suitable to make this.

To clarify what I’m trying to do, I want a 100 hp dummy to be left wth 50 health ( a set value ) if it takes in huge amount of damage or takes damage that leaves it just under 50 (Health < 50)

1 Like

Add value check first

to do that, check first if the damage is morethan 100 then if so then instead deal the full damage change it to 50 and then that’s the time you deliver the value to the health of a humanoid

Make the system determine how much damage needs to be dealt before it actually applies that damage to the Humanoid Health property.

pseudocode:

if dummyHumanoid.Health - damage < 50 then
  dummyHumanoid.Health = 50
end

Here is my code for this (on part touched):

local damage = 900

script.Parent.Touched:Connect(function(hit)
	if damage > 50 then
		hit.Parent.Humanoid:TakeDamage(50)
		print("over 50")
	else
		hit.Parent.Humanoid:TakeDamage(damage)
		print("50 or under")
	end
end)

If you want to cap the damage at 50 (which is what it looks like), all you need to use is math.min().

local damage = 900

enemy.Humanoid:TakeDamage(math.min(50, damage))
1 Like