Wrong scaling with health bar

Problem
I am in the process of making a game and as I was testing out a health bar, I have found a problem in where the health bar wont go down when it takes damage.

Scripts:
main_script

base.Setup(map, 100)
wait(2)
base.update_health(50)

module_script

function base.update_health(damage)
	if damage then
		base.present_health -= damage
	end
	local health_display = game.StarterGui.base_health
	local percent = base.present_health / base.max_health
	
	health_display.present_health.Size = UDim2.new(percent, 0, 0.05, 0)
	health_display.health_display.Text = base.present_health.. "/".. base.max_health
end

Video:

Did you set the anchor point of the frame to 0.5,0.5? (The green part)

no need for anchor points i assume because it only sizes the 1 side, the right one.

in base.present_health is the value from the humanoid health?

No it’s not. Its a value I set in a script and when a mob hits it a part, the health of that mob gets subtracted from the value I put in… like a tds healthbar

can you tell me the value? i assume its more bigger than 100

Oh no it is exactly 100…

(EXTRA WORDS TO FILL)

Did you parent the health bar to the frame? I assume thats the problem here, since in itself that should work already.

i see your problem, you should make it like this,
image


the size becomes the big because you didn’t put a background for max size

	health_display.health_background.present_health.Size = UDim2.new(percent, 0, 0.05, 0)
	health_display.health_display.Text = present_health.. "/".. max_health

Add a frame that same settings/ properties as present_health then change the size of present_health to {1, 0},{1, 0} and make the position to {0, 0},{0, 0} then parent the present_health to the frame you added

Woops ya I forgot to add a bar inside the max health lol

thanks for reminding me