Good evening, I have a health bar I am trying to make which works fine and only stops working after I reset my character. Heres my code below:
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild('Humanoid')
local frame = script.Parent
local HBar = frame.bar
local scale = HBar.Size.X.Scale
function update()
local hp = hum.Health/100
HBar:TweenSize(UDim2.new(hp * scale, 0, 0.48, 0),"Out","Sine",0.5)
print("Updated health")
end
update()
hum.HealthChanged:Connect(update)
Does anyone know how to fix this issue?