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

What's the way to make it where crouching would cancel the sprint?

Asked by 4 years ago
Edited 4 years ago

I've been messing around with this gun script. I have a way to make the sprint cancel the crouch and I can't do it the other way around. How would I do it?

Also another thing is, when I do cancel the crouch with the sprint, how would I make the wait time 0 so the player can crouch once he presses C? Doing Wait (0) doesn't work.

function bindings.KeyPressed(key, mouse)
    local key = key:lower()
    if key == "r" and not reloading and not mouseDown then
        gun.Reload(mouse)
    elseif key == "f" and not reloading and not mouseDown then
        if armToggle.Value then
            armToggle.Value = false
            char.Humanoid.WalkSpeed = 16
            defaultanimation:Play()
            sprintanimation:Stop()
        else
            armToggle.Value = true
            char.Humanoid.WalkSpeed = settings.sprintspeed
            crouchanimation:Stop()
            sprintanimation:Play()
        end
    elseif key == "c" and not armToggle.Value then
        if crouch then
            crouch = false
            char.Humanoid.WalkSpeed = 16
            defaultanimation:Play()
            crouchanimation:Stop()
        else
            crouch = true
            char.Humanoid.WalkSpeed = settings.crouchspeed
            sprintanimation:Stop()
            crouchanimation:Play()
        end
    end
end

Answer this question