GUI horizontal instead of vertical

Im currently making a vertical hunger bar. And its not going as planned because the bar decreases vertically. can anyone help?

local Player = game.Players.LocalPlayer
local Hunger = Player:WaitForChild("Hunger")

local GUI = script.Parent.Parent
local HungerBar = GUI.BehindHunger.Hunger

local function UpdateHunger()
	-- Update the hunger bar size
	local CurrentValue = Hunger.Value 
	local Formula = math.clamp(CurrentValue/100, 0, 1)
	
	HungerBar:TweenSize(UDim2.new(Formula, 0, 1),Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.15, true)
end

UpdateHunger()
Hunger.Changed:Connect(function()
	UpdateHunger() -- Call the function here
end)

this is thebar the orange is the food bar and the dark blue is the back of the bar
image

I assume you want it to look something like this?


where 0% is on the left, 50% is in the middle and 100% is on the right?

If so, you should adjust

HungerBar:TweenSize(UDim2.new(Formula, 0, 1),Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.15, true)

to be

HungerBar:TweenSize(UDim2.new(1, 0, Formula),Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.15, true)

Also, set the initial size to be UDim2.new(1,0,0,0) (or (1,0,1,0), have the anchor point as (0, 1), and the initial position as UDIm2.new(0,0,1,0)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.