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

(Still Unanswered) How to fix this? i'm making custom overhead health GUI

Asked by 5 years ago
Edited 5 years ago

The Code In StarterCharacterScript -

local char = script.Parent
char.Changed:connect(function()
    print("ads")
    local hum = char.Humanoid
    local health = hum.Health
    local maxHealth = hum.MaxHealth
    char.Head.HealthBar.GreenBar.Size = UDim2.new(health/maxHealth,0,1,0)
end)

Also the Billboard GUI is in the characters head

Problem -

Whenever the humanoid takes damage the green bar wont scale to its health.

Also its a billboard GUI in the players head

0
i dont think im correct, but dont you have to make it Health Changed? Kurcha 33 — 5y
0
use a humanoid.HealthChanged event theking48989987 2147 — 5y
0
i tried that ComplexCrypt -5 — 5y
0
You did not specify what the problem is. wilsonsilva007 373 — 5y
0
oh ye ill add that srry ComplexCrypt -5 — 5y

1 answer

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

If I am correct, char is referencing the Player's model instead of the humanoid. If you want the healthbar to update when the player takes damage, then the function must fire when the humanoid changes (specifically the humanoid's health).

Try using this:


local char = script.Parent local human = char:FindFirstChild('Humanoid') human.Changed:connect(function() print('test') local health = human.Health local maxhealth = human.MaxHealth char.Head.HealthBar.GreenBar.Size = UDim2.new(health/maxHealth,0,1,0) end)
0
If you get any errors then comment them plesae Deadman7117 46 — 5y
0
already tried that and no errors the script just wont run or something ComplexCrypt -5 — 5y
0
Ye no matter what i do i try loops functions events it never works ComplexCrypt -5 — 5y
Ad

Answer this question