The Code In StarterCharacterScript -
1 | local char = script.Parent |
2 | char.Changed:connect( function () |
3 | print ( "ads" ) |
4 | local hum = char.Humanoid |
5 | local health = hum.Health |
6 | local maxHealth = hum.MaxHealth |
7 | char.Head.HealthBar.GreenBar.Size = UDim 2. new(health/maxHealth, 0 , 1 , 0 ) |
8 | 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
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:
1 | local char = script.Parent |
2 | local human = char:FindFirstChild( 'Humanoid' ) |
3 |
4 | human.Changed:connect( function () |
5 | print ( 'test' ) |
6 | local health = human.Health |
7 | local maxhealth = human.MaxHealth |
8 | char.Head.HealthBar.GreenBar.Size = UDim 2. new(health/maxHealth, 0 , 1 , 0 ) |
9 | end ) |