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

Why does the second debounce not return like the other variable?

Asked by 7 years ago

I set up a normal Debounce that should make it wait 1 second each time it is run, and I have another form of a debounce within the 'if work == false then' function, but it doesn't work.

Rather than a timer it is supposed to be able to be run once, then when it's run the return function retrieves it as true so the function can no longer be activated and it goes to the end.

Obviously this isn't happening. The rest of the script is a simple(albeit laggy and crude) dash left.

tap = false
Debounce = false
locplay = game.Players.LocalPlayer
human = locplay.Character.Humanoid
game:GetService("UserInputService").InputBegan:connect(function(input1)
    if input1.KeyCode == Enum.KeyCode.A then
if Debounce == false then
wait(1)
Debounce = true
    local work = false
        if work == false then
            if tap then
                print("blah")
                local anim = Instance.new("Animation",human)
                anim.AnimationId = "https://www.roblox.com/DashLEFT-item?id=454485046"
                local animtrack = human:LoadAnimation(anim)
                animtrack:Play()
                for i = 0,-2.5,-.5 do
                    wait(.25)
                local Left = human.Parent.Torso.CFrame * CFrame.new(i,0,0)
                    human.Parent.Torso.CFrame = Left
                end
                animtrack:Stop()
        return
            end
            tap = true
            work = true
            wait(.2)
            tap = false
        end
    end
end
Debounce = false
end)

Thanks.

Answer this question