I have been having trouble with making a custom health bar. What will happen is that it works when you are losing health and die, but it will immediately stop working after you respawn into the game.
local player = game.Players.LocalPlayer
local char = player.Character
local hum = char:WaitForChild("Humanoid")
local TweenService = game:GetService("TweenService")
hum.Changed:connect(function(health)
if health == "Health" or health == "MaxHealth" then
local bar = script.Parent
local info = TweenInfo.new(0.15, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
local goal = {["Size"] = UDim2.new((hum.Health/hum.MaxHealth), 0, 1, 0)}
TweenService:Create(bar, info, goal):Play()
script.Parent.Parent.TextLabel.Text = ("Health: " .. math.floor(hum.Health).."/".. math.floor(hum.MaxHealth))
end
end)
Any help is appreciated.

4 comments
Where is your script located? If you can, please add a picture of its hierarchy.
Maybe the GUI is like "ResetOnSpawn" to false?
I don't think its necessarily a problem with the actual code of the script I think the problem lies within the function, what I did to test this was I put print(hum.Health) inside of the code and it only printed 0 a couple of times and then stopped altogether. Im not completely sure why it didn't update to the point where it went back up to maxhealth.
There is already are tweening methods: TweenSize, TweenPosition, TweenSizeAndPosition, you don't really need to use the garbage tweenservice. kek