Trying to make a custom healthbar, but its position gets messed up when the health changes
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
function resizeCustomLoadingBar(sizeRatio, clipping, top)
clipping.Size = UDim2.new(clipping.Size.X.Scale, clipping.Size.X.Offset, sizeRatio, clipping.Size.Y.Offset)
clipping.Position = UDim2.new(clipping.Position.X.Scale, clipping.Position.X.Offset, 1 - sizeRatio, clipping.Position.Y.Offset)
top.Size = UDim2.new(top.Size.X.Scale, top.Size.X.Offset, 1, top.Size.Y.Offset)
end
function changed()
local healthRatio = humanoid.Health / humanoid.MaxHealth
resizeCustomLoadingBar(healthRatio, script.Parent.Parent, script.Parent)
end
humanoid:GetPropertyChangedSignal("Health"):Connect(changed)

health is at 50% currently (text doesnt update yet)