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
01 | work = false |
02 | tap = false |
03 | locplay = game.Players.LocalPlayer |
04 | human = locplay.Character.Humanoid |
05 | game:GetService( "UserInputService" ).InputBegan:connect( function (input 1 ) |
06 | if input 1. 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 ) |
Gave it a shot - I essentially used tap as the debounce variable, let me know if this does what you need
01 | work = false |
02 | tap = true |
03 | locplay = game.Players.LocalPlayer |
04 | human = locplay.Character.Humanoid |
05 | game:GetService( "UserInputService" ).InputBegan:connect( function (input 1 ) |
06 | if input 1. 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 ) |