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

How can I work a debounce into this script inorder to prevent spam?

Asked by 8 years ago
Edited 8 years ago

I need a Debounce in this script to prevent it from being spammed.

I assume the Debounce needs to be placed within the part unlocked by the return, but I haven't been able to do it.

Putting it outside like normal makes the script stop functioning. Same as inside.

You can spam it easily, an infinitely.

With any debounce I have added, it's caused the script to stop working entirely. EDIT: IT IS SUPPOSED TO ACTIVATE A LEFTWARD DASHING MOTION ON DOUBLE TAP

01work = false
02tap = false
03locplay = game.Players.LocalPlayer
04human = locplay.Character.Humanoid
05game:GetService("UserInputService").InputBegan:connect(function(input1)
06        if input1.KeyCode == Enum.KeyCode.A then
07            if tap then
08                print("blah")
09            local anim = Instance.new("Animation",human)
10                anim.AnimationId = "https://www.roblox.com/DashLEFT-item?id=454485046"
11            local animtrack = human:LoadAnimation(anim)
12                animtrack:Play()
13                for i = 0,-2.5,-.5 do
14                    wait(.25)
15                local Left = human.Parent.Torso.CFrame * CFrame.new(i,0,0)
View all 26 lines...

1 answer

Log in to vote
1
Answered by 8 years ago

Gave it a shot - I essentially used tap as the debounce variable, let me know if this does what you need

01work = false
02tap = true
03locplay = game.Players.LocalPlayer
04human = locplay.Character.Humanoid
05game:GetService("UserInputService").InputBegan:connect(function(input1)
06        if input1.KeyCode == Enum.KeyCode.A then
07            if tap then
08                tap = false
09                print("blah")
10                local anim = Instance.new("Animation",human)
11                anim.AnimationId = "https://www.roblox.com/DashLEFT-item?id=454485046"
12                local animtrack = human:LoadAnimation(anim)
13                animtrack:Play()
14                for i = 0,-2.5,-.5 do
15                    wait(.25)
View all 25 lines...
0
Thanks. You technically answered my question. Unfortunately, I neglected to put what my script was supposed to do. So you answer won't work as the script is supposed to be used on double tap.(Thus the return) pmcdonough 85 — 8y
Ad

Answer this question