Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 13 days ago
Edited 10 days 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 0 — 13d
0
use a humanoid.HealthChanged event theking48989987 1410 — 13d
0
i tried that ComplexCrypt -5 — 13d
0
You did not specify what the problem is. wilsonsilva007 341 — 13d
0
oh ye ill add that srry ComplexCrypt -5 — 12d

1 answer

Log in to vote
0
Answered by 13 days ago
Edited 13 days 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 16 — 13d
0
already tried that and no errors the script just wont run or something ComplexCrypt -5 — 12d
0
Ye no matter what i do i try loops functions events it never works ComplexCrypt -5 — 12d
Ad

Answer this question