Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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:

1local healthLabel = script.Parent.Health
2local boss = workspace:WaitForChild("BossMan")
3local bossHealth = boss.Humanoid.Health
4local bossMaxHealth = boss.Humanoid.MaxHealth
5 
6healthLabel.Text = bossHealth .. "/" .. bossMaxHealth
7boss.Humanoid.HealthChanged:Connect(function()
8    healthLabel.Text = bossHealth .. "/" .. bossMaxHealth
9end)

Any help on this matter would be very appreciated.

0
Update: It actually does update but only after someone dies. comfycouchman 0 — 4y
0
Solution 1; Make it a normal script fishboy141516 12 — 4y
0
Already tried that comfycouchman 0 — 4y
0
solution 2; make the script update everyone second fishboy141516 12 — 4y
View all comments (6 more)
0
What? comfycouchman 0 — 4y
0
I see a main error you did though, you changed the text label twice "healthLabel.Text = bossHealth .. "/" .. bossMaxHealth" and "healthLabel.Text = bossHealth .. "/" .. bossMaxHealth" fishboy141516 12 — 4y
0
You're right, I probably didn't need to include that line, but it doesn't help my situation either. comfycouchman 0 — 4y
0
Actually I did. I removed it and it just broke it even further. comfycouchman 0 — 4y
0
you can try adding a while loop and place this line healthLabel.Text = bossHealth .. "/" .. bossMaxHealth in the loop incurszio 70 — 4y
0
hes right, that would probably work fishboy141516 12 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

you can try this

1local healthLabel = script.Parent.Health
2local boss = workspace:WaitForChild("BossMan")
3local bossHealth = boss.Humanoid.Health
4local bossMaxHealth = boss.Humanoid.MaxHealth
5 
6while true do
7    wait()
8    healthLabel.Text = bossHealth .. "/" .. bossMaxHealth
9end
0
Nope, didn't work. comfycouchman 0 — 4y
0
Are there any errors in the output? incurszio 70 — 4y
0
No comfycouchman 0 — 4y
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 incurszio 70 — 4y
0
Didn't work comfycouchman 0 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Solved it by myself after a while.

Answer this question