Is this even possible? (Show health Value?)

So I want a TextLabel to show the players health in Number form.

But I get an error.

But is it even possible?

Here The Script

script.Parent.Text = game.Players.LocalPlayer.Health.Value

“Value” is not a property of “Health”. Health it self is the value and Health is not a property of the Player and instead within the humanoid of the character.:
script.Parent.Text = game.Players.LocalPlayer.Character.Humanoid.Health

Also if you want it to update every time the health changes you can used GetPropertyChangedSignal():

local Player = game.Players.LocalPlayer

local Character = game.Workspace:WaitForChild(Player.Name)
    script.Parent.Text = Character.Humanoid.Heatlh

This gets me an error

Try this

local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()

	script.Parent.Text = Character.Humanoid.Health

That makes this error

The name of the variable I had put it wrong. Try again.

I’m sorry, but if you’re just gonna copy and paste scripts, you’re making yourself more difficult to solve your problem. Please do not rely on copy and pasting, this wouldn’t make you a successful scripter. Try solving it on your own.

1 Like

Make sure the character is loaded in before it requests it.

Assuming this is a LocalScript (it should be anyways)

First, get the player, then use the player instance to get the character (can be from .Character or .CharacterAdded or even better both!)
Second, invoke WaitForChild with the value “Humanoid” at the character instance you got from declaring it instance
Third, after getting the humanoid, invoke GetPropertyChangedSignal with the value “Health”, it will return a RBXScriptSignal. Connect to the RBXScriptSignal and then change the text with the new health value.

Sorry for the bad explanation, but this is the best I can write along with preventing copy-pasting. Copy-pasting will never lead you anywhere.

Could you try it outside of studio?

1 Like

This should work

local plr = game.Players.LocalPlayer;
local character = plr.Character or plr.CharacterAdded:Wait();
local hum = character:WaitForChild("Humanoid");

   script.Parent.Text = hum.Health; -- assuming script.Parent is a text label

This will keep updating the text of the textlabel to humanoid’s health

1 Like
script.Parent.Text = tostring(game.Players.LocalPlayer.Health.Value)

Incorrect, Health is not a property of LocalPlayer, Health itself is a value of the player’s Humanoid thus, you cannot write ‘Health.Value’ referring to the humanoid’s health.

You can if Health is an IntValue inside of the player sir.

And what is the need to have a separate intvalue for each player’s health when Roblox themselves provide you a Health property in a character’s humanoid?

1 Like

A lot of people use custom health values for specific things like for example if you wanted to make a player have a death animation when they die, or if you don’t want Synapse detecting your health with their built in ESP.

That is not a use case for most of the time, Considering that he has to display the health on textlabel, I DONT find any reason why you need to create a separate IntValue for depicting health, and do all the extra scripting, making events to change the IntValue.

Smart Work > Hard Work

And you would still want to check the Humanoid’s health to change the IntValue in the player unless you want to do the fancy stuff from scratch which is absolutely wasting time.

But hard work benefits you the most.

Anyways regardless to how ‘pointless’ it is, you said I was incorrect just because I was using an alternative method to getting the players health when I based it on how the op made this thread primarily.

And yup I know that, but the provided script that the op gave me was just 1 line. I’m not going to write a whole script down for someone when I can help them solve their problem the ‘smarter’ way.

My bad, but you could have specified other details like creating an int value, scripting its events and change the int value in general, at first glance without any context it is incorrect.

If the op actually had a numbervalue/intvalue inside of the player and was wondering why it wasn’t displaying a stringvalue, then I think this was the right answer to give. It’s pretty straightforward really, I think my updated version says enough about how to fix the issue.