#need help with a sprinting mechanic

1 messages · Page 1 of 1 (latest)

lethal marsh
#

i can still sprint after the bar is empty as long as i am holding down the sprint button

jade rover
#

so it keeps sprinting even when the bar is empty?

carmine monolithBOT
#

studio** You are now Level 2! **studio

lethal marsh
#

but only if i keep holding the shift key down

jade rover
#

you need to make sure that sprinting is set to false immediately when the bar is empty, and also block startSprinting() from being called again until the cooldown is over, even if the sprint key is still held

#

so just replace your startSprinting function with this:

local function startSprinting()
if not sprinting and sprintBarPercent > 0 and not cooldown then
sprinting = true
humanoid.WalkSpeed = sprintSpeed
SprintEvent:FireServer(true)
sprintBar.Visible = true

    -- Run in a separate thread so we don't block other code
    coroutine.wrap(function()
        while sprinting and sprintBarPercent > 0 do
            sprintBarPercent -= 0.02
            updateSprintBar(sprintBarPercent)
            task.wait(0.1)
        end

        if sprintBarPercent <= 0 then
            stopSprinting() -- Stop immediately once depleted
        end
    end)()
end

end

lethal marsh
#

ill test it out when i can

#

thx

eternal yarrow
#

ok

lethal marsh
#

its working

carmine monolithBOT
#

studio** You are now Level 1! **studio

lethal marsh
#

wait i encountered a new bug

#

when i stop sprinting the bar complete disappears