Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to know what a player's health is at all times? (Answered)

I made a script, but it doesn't work. If any could help me it would be great

local Humanoid = game.Players.LocalPlayer.Character.Humanoid
local currentHealth = Humanoid.Health

Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
    print(currentHealth)
end)

2 comments

0

Is there any error's in your developer console?

0

Not that I can see

1 answer

✓ Accepted answer

Hello, ArvidSilverlock!

One way to know a players health at all times is by using the HealthChanged event. This will automatically tell you their new health wether it goes up or down. The script below should help you with your problem. If you find any errors feel free to reply and let me know

HealthChanged is just like the normal Changed event but it's used for health. This event will fire everytime the LocalPlayers health has changed.

Insert a LocalScript into StarterCharacterScripts and put the following code:

local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")

Humanoid.HealthChanged:Connect(function(NewHealth)
	print(NewHealth)
end)

2 comments

0

Thank you!

0

Not a problem. Enjoy making your game!

This discussion is preserved as it was. New answers, comments, and votes are closed.