How can i make this dash script work the way i want?
Asked by
5 years ago Edited 5 years ago
I'm trying to make a script that makes the character model dash backwards when i double tap S. I managed to make the double tap part work but the problem is that the dash animation replays every single time i double tap S.
01 | local UIS = game:GetService( 'UserInputService' ) |
02 | local replicatedStorage = game:GetService( 'ReplicatedStorage' ) |
03 | local backDashEvent = replicatedStorage:WaitForChild( 'DashEvents' ).BackDashEvent |
06 | local player = game.Players.LocalPlayer |
07 | local char = player.Character |
08 | local hum = char:WaitForChild( 'Humanoid' ) |
09 | local root = char:WaitForChild( 'HumanoidRootPart' ) |
12 | local animation = Instance.new( 'Animation' ) |
14 | local load = hum:LoadAnimation(animation) |
20 | UIS.InputBegan:Connect( function (input,gameProcessed) |
21 | if input.KeyCode = = Enum.KeyCode.S and not check and not gameProcessed then |
29 | UIS.InputBegan:Connect( function (input,gameProcessed) |
30 | if input.KeyCode = = Enum.KeyCode.S and check and not gameProcessed then |
33 | backDashEvent:FireServer(root) |
Line 32 i believe is where the problem is. I understand that i need some sort of debounce to put a cooldown on the animation but i'm not sure where i can insert it.