How to change the direction of the GUI Tween?

I’m making a simple “stamina bar” esque gui, where as the player charges up a variable by moving the bar goes up. Except that its not moving upwards and instead from left to right, I’ve never really worked with GUI’s before so I’m not sure if this is a simple fix or not but I would appreciate help

GUI tween script

energyBar:TweenSize(UDim2.new(energy/25,0,1,0),"Out", "Linear", 0)

Full script

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
local energy = 0
local energyBar = script.Parent

local running = false

humanoid.Running:Connect(function(speed)
	running = speed > 5
end)

task.spawn(function()
	while true do
		if running then
			if energy < 25 then
				energy += 1
				energyBar:TweenSize(UDim2.new(energy/25,0,1,0),"Out", "Linear", 0)
			end
		end
		task.wait(.1)
	end
end)

UIS.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 and energy >= 15 then
		energy = 0
	end
end)

The direction the tween goes is shown in red, and the direction I’m trying to make it go is show in black

energyBar:TweenSize(UDim2.new(1,0,energy/25,0),"Out", "Linear", 0)

This makes it move vertically, but it goes from the top of the gui to the bottom

Can you please show a video?__

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
local energy = 0
local energyBar = script.Parent

local running = false

energyBar:TweenSize(UDim2.new(1,0,energy/25,0),"Out", "Linear", 0)
humanoid.Running:Connect(function(speed)
	running = speed > 5
end)

task.spawn(function()
	while true do
		if running then
			if energy < 25 then
				energy += 1
				energyBar:TweenSize(UDim2.new(1,0,energy/25,0),"Out", "Linear", 0)
			end
		end
		task.wait(.1)
	end
end)

UIS.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 and energy >= 15 then
		energy = 0
	end
end)

does this work?

2 Likes

It does the same thing for me unfortunately

You should change the anchor point of the gui from 0,0 to 0,1. It’s a property of the frame and also use Quadro_8000’s code.

3 Likes

Ahh okay his code worked when I changed the anchor point. Thank you both

No problem! As an aside, please mark his answer as the solution.

2 Likes