Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I have made a Stamina Bar. How do you make it decrease vertically? Thank you for your time!

Asked by 4 years ago
Edited 4 years ago

I made a stamina bar in Roblox Studio and the script works completely fine, but when I sprint the bar decreases horizontally. I want it to go down vertically. I would be really happy if you could help me. I'm also new to scripting. Thank you for your time.

Anyways here is the script I wrote:

local bar = script.Parent

local stamina = 100 local staminaRate = 1

local plr = game.Players.LocalPlayer local char = plr.Character or plr.CharacterAdded:Wait()

local humanoid = char:WaitForChild("Humanoid")

local isSprinting = false

local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(key, gameProcessed)

if gameProcessed or stamina == 0 then return end

if key.KeyCode == Enum.KeyCode.LeftControl then

    isSprinting = not isSprinting

    if isSprinting then
        humanoid.WalkSpeed = 25
    else
        humanoid.WalkSpeed = 16
    end
end

end)

while wait() do

if stamina == 0 and isSprinting then

    isSprinting = false
    humanoid.WalkSpeed = 16
end

if isSprinting and humanoid.MoveDirection.Magnitude > 0 then

    stamina = stamina - 1
    wait(staminaRate)

else
    stamina = stamina + 1
    wait(staminaRate)
end

stamina = math.clamp(stamina, 0, 100)

bar:TweenSize(UDim2.new((1/100) * stamina, 0, 1 ,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.5)

end

Thank you for your time!

1 answer

Log in to vote
0
Answered by
abrobot 44
4 years ago

try replacing line 19 with

bar:TweenSize(UDim2.new(0, 0, (1/100) * stamina ,0),
Ad

Answer this question