Hello everyone!
This may be a common problem for many people. Let me explain.
I have a health bar that has a hierarchy like this:
I have set the UICorners to (0.5, 0) for both frames. To make the health bar work, I have used this code:
local tweenService = game:GetService("TweenService")
local invisBar = script.Parent.InvisBar
local backgroundBar = invisBar.BackgroundBar
local healthBar = backgroundBar.HealthBar
local player = game.Players.LocalPlayer
repeat
wait()
until player.Character.Humanoid
local function updateUI()
local currentHealth = player.Character.Humanoid.Health
local maxHealth = player.Character.Humanoid.MaxHealth
local tween = tweenService:Create(healthBar, TweenInfo.new(0.35, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), { Size = UDim2.new(currentHealth / maxHealth, 0, 1, 0) })
tween:Play()
end
player.Character.Humanoid:GetPropertyChangedSignal("Health"):Connect(updateUI)
player.Character.Humanoid:GetPropertyChangedSignal("MaxHealth"):Connect(updateUI)
This is all good, but watch what happens when we set the player’s health to 1 (or another small number):
We get a very weird clipping effect! I know we can solve this with ClipDescendants, but I don’t know how to use it!
I have seen many reports on this issue on the dev forum, but many are problem-specific (only concerning their code and work style), not a general fix!
Do you guys know how to solve this issue? If so, please get back to me!
Thanks!
- GreenTree Gaming