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.
local UIS = game:GetService('UserInputService')
local replicatedStorage = game:GetService('ReplicatedStorage')
local backDashEvent = replicatedStorage:WaitForChild('DashEvents').BackDashEvent
local player = game.Players.LocalPlayer
local char = player.Character
local hum = char:WaitForChild('Humanoid')
local root = char:WaitForChild('HumanoidRootPart')
local animation = Instance.new('Animation')
animation.AnimationId = 'rbxassetid://04793471389'
local load = hum:LoadAnimation(animation)
local check = false
UIS.InputBegan:Connect(function(input,gameProcessed)
if input.KeyCode == Enum.KeyCode.S and not check and not gameProcessed then
check = true
wait(0.2)
check = false
end
end)
UIS.InputBegan:Connect(function(input,gameProcessed)
if input.KeyCode == Enum.KeyCode.S and check and not gameProcessed then
load:Play() <----- the animation replays every time i double tap S
backDashEvent:FireServer(root)
check = false
end
end)
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.

1 comment
You can use animation.Stopped, then animation:Stop() I think.