How to print reduced health?

@Proville6’s method should work right?

local LastHP = Humanoid.Health
Humanoid.HealthChanged:Connect(function(hp)
	local difference = hp-LastHP
	
	if difference < 0 then
		-- Took damage
	else
		-- Healed
	end
	
	LastHP = hp
end)
2 Likes

I don’t understand what you mean ? :neutral_face:

1 Like

i just said that it works smoothly in a local script in starter character scripts
( i tested it )

2 Likes

Isnt that just my method but just smaller?

1 Like

Yes I agree, but if you remove your current life from your max life your script will say the good damage only 1 time!

1 Like

i guess cause i didnt saw yours so…

1 Like

it wont jeez cant you see? test it your self!

local hum:Humanoid =script.Parent:WaitForChild("Humanoid")
local Health = hum.MaxHealth
hum.HealthChanged:Connect(function(CurHealth)
	print(Health-CurHealth)
	Health = hum.Health
end)
3 Likes

Guys I just got a new problem.

I went in the damage script of the NPC and did this :

But for some reason it prints ‘false’ even tho it’s true :confused:

1 Like

You should probably create a new topic for that since its not related.

1 Like

Oh sorry it’s me! I am a beginner and I did not read your code well! :sweat_smile:

1 Like

hmm that maybe be due to you making it true on the client

1 Like

Oh I see! Well its ok if your a beginner.

1 Like

But this work?

2 Likes

So that :

Humanoid.HealthChanged:Connect(function(Health)
    print(Humanoid.MaxHealth - Health)
end)
1 Like

Nope, it doesn’t work at all… ;(

1 Like

it wont cause your taking it from the max health example
current health(1) = 90
max health = 100
took health = -10
current health(2) = 80
prints = max health - current health(1) == 20

2 Likes

I’ve got it thank you ! :joy::sweat_smile:
it’s work ?

local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local Health = Humanoid.MaxHealth

Humanoid.HealthChanged:Connect(function()
	print(Humanoid.Health - Health)
	Health = Humanoid.Health
end)
1 Like

yes but i suggest not using this topic anymore do it in the dms