Help with Health GUI

Why isn’t this working? The text doesnt change and the bar isn’t being tweened. I want to make a health bar gui, that changes whenever u take damage or when ur max health changes. i get all the prints,no output errors, and its in a local script.

local bar = script.Parent
local text = script.Parent.Parent.hpText

local player = game.Players.LocalPlayer
local char = player.Character
local humanoid = char:WaitForChild("Humanoid")
local health = humanoid.Health
local maxhealth = humanoid.MaxHealth

text.Text = (health).." / "..(maxhealth)

local change = (health) / (maxhealth)
bar:TweenSize(UDim2.new(change,0,1,0), "In", "Linear", 0.5)

humanoid:GetPropertyChangedSignal("Health"):Connect(function()
	print("1")
	text.Text = (health).." / "..(maxhealth)
	print("2")
	local change =(health) / (maxhealth)
	print("3")
	bar:TweenSize(UDim2.new(change,0,1,0), "In", "Linear", 0.5)
	print("4")
end)

humanoid:GetPropertyChangedSignal("MaxHealth"):Connect(function()
	text.Text = (health).." / "..(maxhealth)
	local change = (health) / (maxhealth)
	bar:TweenSize(UDim2.new(change,0,1,0), "In", "Linear", 0.5)
end)

What’s not working you haven’t even said. No errors?
and the change variable line should be

local change = (health / maxhealth)

Have you verified you aren’t only damaging it from the client and it isn’t replicating? This is a common mistake made if so.

The text doesnt change, and the bar doesnt get tweened

Can you be specific as to what is not working?

On first read these are the errors I see:

-The first mistake I noticed just reading your code is that you just put the change of health/MaxHealth into the UDim2 offset x during tweening. You have to multiply the original offset x size by the change(health/Maxhealth) to get results relative to the size of the ui bar.

-The 2nd mistake is that you need to re-define the variable in for health after :GetPropertyChangedSignal(“Health”). If you try printing health and maxhealth in the :GetPropertyChangedSignal() functions you are going to get the original pre-defined hp and max hp(Health = Humanoid.Health) which is most likely going to be 100 and 100.

As @Thereasonableplayer said the health variable is not being updated since you only indexed it at the beginning of the script, just update it inside of the :GetPropertyChangedSignal() function.