Health Bar GUI Increases in Size When Taking Damage

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to fix the issue of the health bar increasing in size when taking damage.

  1. What is the issue? Include screenshots / videos if possible!

As stated before, the health bar increases in size when taking damage.

Here are a few screenshots of the GUI and the code

Screen Shot 2022-07-13 at 10.29.02 PM

This is what happens when you take damage

Notice how the health bar is totally fine before you take damage and then all of a sudden its size increases.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have tried using other peoples codes but their code resulted in the same thing happening. Maybe it has something to do with the frames itself?

1 Like

Change your script to this:

Humanoid.HealthChanged:Connect(function()
    script.Parent.Size:TweenSize(Udim2.new(Humanoid.Health/Humanoid.MaxHealth, 0, 1, 0), Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 1)
end)

Note: Keep the variables from your og script.

Explanation: you want to divide the current health by the max health to get the correct size.

1 Like

Its supposed to be like
Background → Bar
you did it opposite (Bar → Background)

1 Like

Delete the .Size part. :TweenSize() doesn’t need to have the Size property referenced for a guiObject, only the gui itself.

1 Like

the same thing happens. The gui gets bigger when taking damage but the only difference is that there’s a tween animation