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

Is it possible to put only one debounce to 2 functions?

Asked by 4 years ago

I want to put my Mouse.Button1Down and Mouse.Button1Up in only one debounce. I don't know if it's even possible and how.

script.Parent.Equipped:Connect(function(mouse)

    mouse.Button1Down:Connect(function()
            lunge:Play()
    end)

    mouse.Button1Up:Connect(function()
            lunge:Stop()
            slash:Play()
            wait(1)
            slash:Stop()

            script.Parent.Blade.Touched:Connect(function(hit)
                if CanDamage.Value == true then
                    CanDamage.Value = false
                    hit.Parent.Humanoid:TakeDamage(damage)
                end
            end)
    end)
end)
0
Yes. JesseSong 3916 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

I don't think this is possible, and even if it is, it is surely difficult to do. It is much easier and simpler to use two debounces:

local buttonUpDebounce, buttonDownDebounce = false, false
Ad
Log in to vote
0
Answered by 4 years ago

This doesn't answer your question, but you're hooking the Equipped event with the mouse parameter included, that's fine, but you're also trying to damage the humanoid on line 16. Either client-script or server-script, this won't work.

Server scripts can hook the Equipped event, but it doesn't include the mouse object. Client scripts can hook the Equipped event, but you cannot damage a Humanoid on the client and let it replicate- Unless FilteringEnabled is disabled, in which your game in vulnerable to exploits.

Answer this question