for some reason when i dash and press Q then press W if i press another key like A it will dash again any help would be appreciated
heres the code btw this is not my script just changed it a little
local increment = ((dashEndSpeed- dashStartSpeed) / (dashDuration* 60)) * 2 -- Simple velocity calculation
local BodyVelocity = Instance.new("BodyVelocity", HRP)
BodyVelocity.MaxForce = Vector3.new(math.huge,0,math.huge)
gameSettings.RotationType = Enum.RotationType.CameraRelative --Makes player follow mouse)
local directionalForce
if direction == "forward" or direction == "right" then
directionalForce = 1 -- Imagine that the player position is a graph/2d coordinate, if all values => 0 then its either going up or left
elseif direction == "backward" or direction == "left" then
directionalForce = -1 -- And if its all =< 0 then its either going down or left (this works because the dash only changes X or Y value, not both at once)
end
for i=dashStartSpeed,dashEndSpeed,increment do
if direction == "forward" or direction == "backward" then
local MoveDirection = HRP.CFrame.LookVector
if Humanoid:GetState() == Enum.HumanoidStateType.Jumping or Humanoid:GetState() == Enum.HumanoidStateType.Freefall or Humanoid:GetState() == Enum.HumanoidStateType.FallingDown then
BodyVelocity.Velocity = Vector3.new(MoveDirection.X * i * directionalForce, 0, MoveDirection.Z * i * directionalForce) / 1.25 -- So that you dash less further in air
wait()
else
BodyVelocity.Velocity = Vector3.new(MoveDirection.X * i * directionalForce, 0, MoveDirection.Z * i * directionalForce)
wait()
end
elseif direction == "left" or direction == "right" then
local MoveDirection = HRP.CFrame.RightVector
if Humanoid:GetState() == Enum.HumanoidStateType.Jumping or Humanoid:GetState() == Enum.HumanoidStateType.Freefall or Humanoid:GetState() == Enum.HumanoidStateType.FallingDown then
BodyVelocity.Velocity = Vector3.new(MoveDirection.X * i * directionalForce, 0, MoveDirection.Z * i * directionalForce) / 1.25 -- So that you dash less further in air
wait()
else
BodyVelocity.Velocity = Vector3.new(MoveDirection.X * i * directionalForce, 0, MoveDirection.Z * i * directionalForce)
wait()
end
end
end
BodyVelocity:Destroy()
gameSettings.RotationType = Enum.RotationType.MovementRelative
end
--test and instructions
--Adjust variables beforehand, this test simulates W being held
local ForwardDashDirection
local ForwarddashStartSpeed = 55
local ForwarddashDuration = 0.60
local ForwarddashEndSpeed = 16
local BackDashDirection
local BackdashStartSpeed = 44
local BackdashDuration = 0.50
local BackdashEndSpeed = 16
local LeftDashDirection
local LeftdashStartSpeed = 44
local LeftdashDuration = 0.50
local LeftdashEndSpeed = 16
local RightDashDirection
local RightdashStartSpeed = 44
local RightdashDuration = 0.50
local RightdashEndSpeed = 16
local Front = Humanoid:LoadAnimation(FrontD)
local Back = Humanoid:LoadAnimation(BackD)
local left = Humanoid:LoadAnimation(LeftD)
local right = Humanoid:LoadAnimation(RightD)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
if Character:GetAttribute("Dash") == true then return end
Character:SetAttribute("Dash",true)
if UIS:IsKeyDown(Enum.KeyCode.W) then
Character:SetAttribute("Dash",true)
Front:Play()
Front:AdjustSpeed(0.7)
ForwardDashDirection = "forward"
dashFunction("forward", ForwarddashStartSpeed, ForwarddashDuration, ForwarddashEndSpeed)
task.wait(1)
Bdebounce = false
Character:SetAttribute("Dash",false)
end
if UIS:IsKeyDown(Enum.KeyCode.S) then
Character:SetAttribute("Dash",true)
BackdashDuration = "backward"
Back:Play()
dashFunction("backward", RightdashStartSpeed, RightdashDuration, RightdashEndSpeed)
task.wait(0.7)
Bdebounce = false
Character:SetAttribute("Dash",false)
end
if UIS:IsKeyDown(Enum.KeyCode.D) then
Character:SetAttribute("Dash",true)
right:Play()
RightDashDirection = "right"
dashFunction("right", RightdashStartSpeed, RightdashDuration, RightdashEndSpeed)
task.wait(0.7)
Bdebounce = false
Character:SetAttribute("Dash",false)
end
if UIS:IsKeyDown(Enum.KeyCode.A) then
Character:SetAttribute("Dash",true)
left:Play()
LeftDashDirection = "left"
dashFunction("left", LeftdashStartSpeed, LeftdashDuration, LeftdashEndSpeed)
task.wait(0.7)
Bdebounce = false
Character:SetAttribute("Dash",false)
end
end```