Custom Health Bar Issue

Hello developers, I followed a tutorial on how to make a custom healthbar a while back but I also noticed a problem. Whenever I zoom in my camera the healthbar becomes bigger and whenever I zoom out it becomes smaller and also the text doesen’t seem to fit it whenever its too small.

Video:
robloxapp-20220623-2052077.wmv (1.5 MB)

Here’s the script:

gui = script.Parent

char = gui.Parent

humanoid = char:FindFirstChild("Humanoid")

healthbar = gui.Healthbar

healthDisplay = gui.HealthDisplay

gui.Adornee = char:FindFirstChild("Head")

function updateDisplay()

healthDisplay.Text = math.floor(humanoid.Health) .. "/" ..humanoid.MaxHealth

healthbar:TweenSize(UDim2.new(humanoid.Health / humanoid.MaxHealth, 0, 1 , 0))

end

updateDisplay()

humanoid.HealthChanged:Connect(updateDisplay)

Thanks!

Please show the properties of the gui in the explorer window.

Here’s my healthbar properties:

Oh i didnt realize it was a Billboard Gui… for the BillboardGui, in the Size property you will want to use Offset instead of Scaled, this will keep the text the same size no matter how you zoom in or out. Try this out.

Well also inside of the billboard theres 2 frames.

1 Like

Does it mess with those frames?

ye and for the offset inside scale it didnt work

You mean inside Size? Use offset instead of the scale values, so like (0,10,0,15) for example.

do you mean by this?
OffsetHealthbar

1 Like

Yes… for both X and Y values. . .

well I cant use decimal numbers so instead of 3.6 and 0.5 I did 360 and 50. The frame it self still scales out when you zoom out/the more your further from it and when you zoom in/the more you come closer from it becomes smaller

Is the text in the inner frames?

no the parent is the billboard gui inside the frame is just ui corners.
HealthBarTextLabelHighLight

Hmmm try maybe changing the frames to offset as well.

It doesent seem to work nothings changing

1 Like

Im not sure but i believe the tween in your script also needs to be offset but lets see if anyone else has ideas before you go trying that.

1 Like