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 3 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:

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.

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

2 answers

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

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
0
Nope, didn't work. comfycouchman 0 — 3y
0
Are there any errors in the output? incurszio 70 — 3y
0
No comfycouchman 0 — 3y
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 — 3y
0
Didn't work comfycouchman 0 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Solved it by myself after a while.

Answer this question