Advertisement
SxScripting

Debounce Double Tap W

Mar 6th, 2021
11,432
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 1 0
  1. local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
  2. local UIS = game:GetService('UserInputService')
  3. local LastTapped,Tapped = false,false
  4. local Run = Humanoid:LoadAnimation(script:WaitForChild("Run"))
  5.  
  6. UIS.InputBegan:Connect(function(Input, IsTyping)
  7. if IsTyping then return end
  8. if Input.KeyCode == Enum.KeyCode.W then
  9. if Tapped == false then
  10. Tapped = true
  11. else
  12. LastTapped = true
  13. Tapped = false
  14. Run:Play()
  15. Humanoid.WalkSpeed = 32
  16. end
  17.  
  18. delay(.4, function()
  19. if Tapped then
  20. Tapped = false
  21. end
  22. end)
  23.  
  24. end
  25. end)
  26.  
  27. UIS.InputEnded:Connect(function(Input, IsTyping)
  28. if IsTyping then return end
  29. if Input.KeyCode == Enum.KeyCode.W and LastTapped and not Tapped then
  30. Humanoid.WalkSpeed = 16
  31. Run:Stop()
  32. end
  33. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement