I’ve made a cooldown for a move and to use the move you have to double tap w I made a debounce cool down for the move but it doesn’t work and on top of that if you keep holding down w it repeats the move multiple times how could I fix this? Code:
local function CheckSpecialFlight()
local wTbl = flightControls.W
local currentWVel = vel[wTbl.Axis] * wTbl.VelSign
if (not latching) then
if keysDown.DoubleW and keysDown.W and rushDeb == false then
RushVfx(char, team, lockedTarget)
rds.Remotes.Flight:FireServer("rush", lockedTarget)
task.wait(settingsModule.RushDelay)
local doubleWTbl = flightControls.DoubleW
local disfrom = (plr.Character.HumanoidRootPart.Position - lockedTarget.HumanoidRootPart.Position).Magnitude
if disfrom <= 100 then
elseif disfrom > 100 then return end
plr.Character.HumanoidRootPart.CFrame = lockedTarget.HumanoidRootPart.CFrame * CFrame.new(-6,0,0)
-- adding same effect after teleporting
local Rushit_sound = game.ReplicatedStorage.Assets.SFX.RushHit
Rushit_sound:Play()
local function RushVfx(vfxChar, vfxTeam, enemyVfxChar)
local vfxHrp = vfxChar:FindFirstChild("HumanoidRootPart")
local enemyVfxHrp = enemyVfxChar:FindFirstChild("HumanoidRootPart")
if vfxHrp and enemyVfxHrp then
local cf = CFrame.lookAt(vfxHrp.Position, enemyVfxHrp.Position) * CFrame.new(0, 0, -4)
local rushVfxPart = rds.Assets.VFX.RushVfx_new:Clone()
rushVfxPart.CFrame = cf
rushVfxPart.Parent = workspace.Debris
EmitParticles(rushVfxPart)
dbs:AddItem(rushVfxPart, 1.5)
end
end
end
rushDeb = true
playRushAnim = true
keysDown.DoubleW = false
rushReached = false
task.delay(settingsModule.RushCooldownDuration, function()
rushDeb = false
end)
local function CheckSpecialFlight()
local wTbl = flightControls.W
local currentWVel = vel[wTbl.Axis] * wTbl.VelSign
if (not latching) then
if keysDown.DoubleW and keysDown.W and rushDeb == false then
RushVfx(char, team, lockedTarget)
rds.Remotes.Flight:FireServer("rush", lockedTarget)
task.wait(settingsModule.RushDelay)
local doubleWTbl = flightControls.DoubleW
local disfrom = (plr.Character.HumanoidRootPart.Position - lockedTarget.HumanoidRootPart.Position).Magnitude
if disfrom <= 100 then
elseif disfrom > 100 then return end
plr.Character.HumanoidRootPart.CFrame = lockedTarget.HumanoidRootPart.CFrame * CFrame.new(-6,0,0)
-- adding same effect after teleporting
local Rushit_sound = game.ReplicatedStorage.Assets.SFX.RushHit
Rushit_sound:Play()
local function RushVfx(vfxChar, vfxTeam, enemyVfxChar)
local vfxHrp = vfxChar:FindFirstChild("HumanoidRootPart")
local enemyVfxHrp = enemyVfxChar:FindFirstChild("HumanoidRootPart")
if vfxHrp and enemyVfxHrp then
local cf = CFrame.lookAt(vfxHrp.Position, enemyVfxHrp.Position) * CFrame.new(0, 0, -4)
local rushVfxPart = rds.Assets.VFX.RushVfx_new:Clone()
rushVfxPart.CFrame = cf
rushVfxPart.Parent = workspace.Debris
EmitParticles(rushVfxPart)
dbs:AddItem(rushVfxPart, 1.5)
end
end
rushDeb = true
playRushAnim = true
keysDown.DoubleW = false
rushReached = false
task.delay(settingsModule.RushCooldownDuration, function()
rushDeb = false
end
end)
local function CheckSpecialFlight()
local wTbl = flightControls.W
local currentWVel = vel[wTbl.Axis] * wTbl.VelSign
if (not latching) then
if keysDown.DoubleW and keysDown.W and rushDeb == false then
rushDeb = true
RushVfx(char, team, lockedTarget)
rds.Remotes.Flight:FireServer("rush", lockedTarget)
task.wait(settingsModule.RushDelay)
local doubleWTbl = flightControls.DoubleW
local disfrom = (plr.Character.HumanoidRootPart.Position - lockedTarget.HumanoidRootPart.Position).Magnitude
if disfrom <= 100 then
elseif disfrom > 100 then return end
plr.Character.HumanoidRootPart.CFrame = lockedTarget.HumanoidRootPart.CFrame * CFrame.new(-6,0,0)
-- adding same effect after teleporting
local Rushit_sound = game.ReplicatedStorage.Assets.SFX.RushHit
Rushit_sound:Play()
local function RushVfx(vfxChar, vfxTeam, enemyVfxChar)
local vfxHrp = vfxChar:FindFirstChild("HumanoidRootPart")
local enemyVfxHrp = enemyVfxChar:FindFirstChild("HumanoidRootPart")
if vfxHrp and enemyVfxHrp then
local cf = CFrame.lookAt(vfxHrp.Position, enemyVfxHrp.Position) * CFrame.new(0, 0, -4)
local rushVfxPart = rds.Assets.VFX.RushVfx_new:Clone()
rushVfxPart.CFrame = cf
rushVfxPart.Parent = workspace.Debris
EmitParticles(rushVfxPart)
dbs:AddItem(rushVfxPart, 1.5)
end
end
playRushAnim = true
keysDown.DoubleW = false
rushReached = false
task.delay(settingsModule.RushCooldownDuration, function()
rushDeb = false
end
end)