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

How To Make My Health Display On a TextLable?

I don't know what wrong with it All I want Is for my current humanoid health display on my Text Table

local player = game.Players.LocalPlayer
local hum = player.Character.Humanoid
local lable = script.Parent
local health = player.HealthHealth
lable.Text = player.Health``

This is for a health bar ofcoure

1 answer

Now first of all, players do not have health. A player's character's humanoid will have health. So line five will error.

Secondly, you aren't updating the script to reflect changes in health. It's like if I told you tell me what colour my shirt is before I change into a new one and then wonder why you didn't tell me what colour my new shirt is.

Most properties can be listened for changes in using GetPropertyChangedSignal(property). In your case, you should be waiting for Humanoid:GetPropertyChangedSignal("Health") to fire.

Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
	Label.Text = Humanoid.Health
end)

This is an example so you'll have to change variables to fit your script accordingly.

2 comments

0

I Did This But It still doesn't Work --- local player = game.Players.LocalPlayer local Humanoid = player.Character.Humanoid local Label = script.Parent Humanoid:GetPropertyChangedSignal("Health"):Connect(function() Label.Text = Humanoid.Health end)

0

Does it error? Is this in a local script? Is the label variable properly defined?

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