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

Why doesn't the TextLabel update with the humanoid's health?

I made a sort of boss bar where it displays the boss's current health and max health. Obviously it's supposed to update whenever it's health changes, but it isn't. There are no errors either. Here's my local script:

local healthLabel = script.Parent.Health
local boss = workspace:WaitForChild("BossMan")
local bossHealth = boss.Humanoid.Health
local bossMaxHealth = boss.Humanoid.MaxHealth

healthLabel.Text = bossHealth .. "/" .. bossMaxHealth
boss.Humanoid.HealthChanged:Connect(function()
	healthLabel.Text = bossHealth .. "/" .. bossMaxHealth
end)

Any help on this matter would be very appreciated.

10 comments

0

Update: It actually does update but only after someone dies.

0

Solution 1; Make it a normal script

0

Already tried that

0

solution 2; make the script update everyone second

0

What?

0

I see a main error you did though, you changed the text label twice "healthLabel.Text = bossHealth .. "/" .. bossMaxHealth" and "healthLabel.Text = bossHealth .. "/" .. bossMaxHealth"

0

You're right, I probably didn't need to include that line, but it doesn't help my situation either.

0

Actually I did. I removed it and it just broke it even further.

0

you can try adding a while loop and place this line healthLabel.Text = bossHealth .. "/" .. bossMaxHealth in the loop

0

hes right, that would probably work

2 answers

you can try this

local healthLabel = script.Parent.Health
local boss = workspace:WaitForChild("BossMan")
local bossHealth = boss.Humanoid.Health
local bossMaxHealth = boss.Humanoid.MaxHealth

while true do
	wait()
	healthLabel.Text = bossHealth .. "/" .. bossMaxHealth
end

5 comments

0

Nope, didn't work.

0

Are there any errors in the output?

0

No

0

https://prnt.sc/zs73r1 ok click on the button i circled and then change the humanoids health while you're in the server check if the label updates then

0

Didn't work

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