Bar goes upwards when y value decreases

Hello, developers!

I’m having a problem with tweening a UI. It’s meant to tween based on the player’s health, but instead of going downwards, it goes upwards:

image

My code:

local plr = game:GetService("Players").LocalPlayer
repeat wait() until plr.Character or plr.CharacterAdded:wait()
local char = plr.Character or plr.CharacterAdded:wait()
local hum = char:WaitForChild("Humanoid")

local bar = script.Parent.Frame.Holder.Bar

while wait() do
	bar:TweenSize(UDim2.new(1, 0,hum.Health/hum.MaxHealth, 0),"Out","Linear",0.2,true)
	bar.BackgroundColor3 = Color3.fromRGB(255, 51, 54):Lerp(Color3.fromRGB(17, 255, 104),hum.Health/hum.MaxHealth)	
end

Any suggestions are appreciated!

1 Like

Try setting the AnchorPoint of the bar to 0, 1 and the Position to 0, 0, 1, 0 :slightly_smiling_face:

This will make the bar “stick” to the bottom of the frame it’s inside, even as it gets smaller. This is because the AnchorPoint will tell Roblox to move the bottom left corner of the bar to whatever Position is set to, and we then set Position to the bottom left corner of the frame.

6 Likes