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

How to make sprint bar not go negative?

Asked by 5 years ago

I found a bug that makes sprint bar go negative and still allow player to sprint. How can I remove that?

while wait() do
    if enabled.Value == true then
        if humanoid then
            if humanoid.MoveDirection == Vector3.new(0,0,0) then moving = false else moving = true end
            if tired then 
                ChangeSpeed(exhaust.Value) -- Rest
                Frame.Rest1.Visible = true
                if not moving then
                    stamina = stamina + 2
                end
                if stamina > 0 then
                    tired = false
                    Frame.Rest1.Visible = false
                    Frame.GreenBar:TweenSize(UDim2.new(3.5*stamina/875,0, 0,12), "Out", "Quad", 0.1, true)
                end
            elseif running == true then
                if moving then
                    ChangeSpeed(run.Value) -- Sprint
                    stamina = stamina - 2
                    Frame.GreenBar:TweenSize(UDim2.new(3.5*stamina/875,0, 0,12), "Out", "Quad", 0.1, true)
                    if stamina == 0 then tired = true stamina = -10 end -- i think this is the culprit, but I don't know a work around it.
                elseif stamina < 250 then
                    stamina = stamina + 1
                    Frame.GreenBar:TweenSize(UDim2.new(3.5*stamina/875,0, 0,12), "Out", "Quad", 0.1, true)
                end
            else ChangeSpeed(walk.Value) -- Walk
                if moving and stamina < 250 then
                    stamina = stamina + 1
                    Frame.GreenBar:TweenSize(UDim2.new(3.5*stamina/875,0, 0,12), "Out", "Quad", 0.1, true)
                elseif not moving and stamina < 250 then
                    stamina = stamina + 1
                    Frame.GreenBar:TweenSize(UDim2.new(3.5*stamina/875,0, 0,12), "Out", "Quad", 0.1, true)
                elseif moving and stamina >0 then --I added this, but still not working
                    tired = true

                end
            end
        end
    end
    end

1 answer

Log in to vote
0
Answered by 5 years ago

I am dumn to not realized that >0 is supposed to be > 0

elseif moving and stamina < 0 then
tired = true
0
Heh Torren_Mr 334 — 5y
0
;) KingDomas 153 — 5y
Ad

Answer this question