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
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
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)