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

Can anyone figure out how to add Debounce to uis.inputended?

Asked by 8 years ago

****MY big ugly code dont hate ;(

local req = 0
local LCV  --Lets make this nill
local deb = false 

uis.InputBegan:connect(function(input, GPE)
    if GPE then return end
    if input.KeyCode == Enum.KeyCode.E then
        if not deb then
        deb = true
        req = 0
        LCV = true

        local human = char.Humanoid
        ani.AnimationId = "http://www.roblox.com/asset?id=387149840"
            if human then
                local load = human:LoadAnimation(ani)
                if load then
                load:Play()
            end
        end 


        while LCV do
        wait(1)
        req = req + 1
        print 'added 1'
        end


        end

    wait(2)
    deb = false
    print 'cooled'
        end
end)



uis.InputEnded:connect(function(input)--Aftet button was released
    if input.KeyCode == Enum.KeyCode.E then
        LCV = false
        print(req)
        ani.AnimationId = "http://www.roblox.com/asset?id=387152305"

        local hu = char.Humanoid
        if hu then
            local load = hu:LoadAnimation(ani)
            if load then
            load:Play()

            wait(2)
            load:Stop()
            end
        end 
    end
end)

1 answer

Log in to vote
0
Answered by
Lamar 45
8 years ago

Declare the debounce variable outside the function and change it within the function. That way, the variable isn't overridden every time you run the function.

local debounce = false --look at me! I'm outside the function!

function doStuff()
    if debounce then --return nothing and exit the function if debounce is true
        return
    else
        debounce = true
        --do stuff!
        debounce = false
    end
end
0
isnt very helpful i already know how this works.... xlaser23 60 — 8y
0
So then use the same principle for InputEnded. Lamar 45 — 8y
Ad

Answer this question