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

Some One Help ME Whit Stamina Bar Jumpig + Running?

Asked by 3 years ago

Hello,Im Doing Stamina Bar But Is Not Working SOme OnE can Help Me?

local player = game.Players.LocalPlayer
local character = player.character
local s = script.Parent.B

local UserInputService = game:GetService("UserInputService")

local stamina = 200
local running = false
local jumping = false


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

UserInputService.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift or Enum.KeyCode.Space then
        running = true 
        character.Humanoid.WalkSpeed = 26
        while stamina > 0 and running and jumping do
            stamina = stamina - 1
            s:TweenSize(UDim2.new(stamina /200,0,1,0), "Out", "Linear", 0)
            wait ()
            if stamina == 0 then 
                character.Humanoid.WalkSpeed = 0
                character.Humanoid.JumpPower = 0
            end
        end
    end
end)

UserInputService.InputEnded:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift or Enum.KeyCode.Space then
        running = false
        character.Humanoid.WalkSpeed = 16
        while stamina < 200 and not running and not jumping do
            stamina = stamina + 1
            s:TweenSize(UDim2.new(stamina /200,0,1,0), "Out", "Linear", 0)
            wait()
            if stamina == 0 then
                character.Humanoid.WalkSpeed = 0
                character.Humanoid.JumpPower = 0
            end
        end
    end
end)

0
Why don't you just make jumping remove a set amount of stamina and on line 18 only check for running? cmgtotalyawesome 1418 — 3y
0
i want do a jumping and walking script joaq2300 7 — 3y

Answer this question