My dashing script which works fine after doing the normal front, left, right, back dashes, works weird when i implemented a system where going backwards allows you to go forwards instantly. That implementation caused the bodyvelocity to work longer and stronger rather than doing the nomral front dash. Heres an example:
Now here is the code:
local function Dash()
if Human.MoveDirection.Magnitude <= 0 then
return
end
local RelativeDirection = Camera.CFrame:VectorToWorldSpace(ControlModule:GetMoveVector()) * Vector3.new(1,0,1)
local Direction = GetAnimation(RelativeDirection, Root.CFrame)
if lastDirection == "Backwards" and Direction == "Forwards" then
breakLoops = true
if Connection then
Connection:Disconnect()
Connection = nil
end
local PreviousDash = Root:FindFirstChild("BodyVelocity")
if PreviousDash then
PreviousDash:Destroy()
end
DashDebounce = false
end
lastDirection = Direction
if DashDebounce then
return
end
DashDebounce = true
task.delay(cooldown, function()
DashDebounce = false
end)
local NewBV = BV:Clone()
NewBV.MaxForce = Vector3.new(1,0,1) * 1000000
NewBV.Parent = Root
local multi = 2.00
Connection = RunService.RenderStepped:Connect(function(dt)
NewBV.Velocity = RelativeDirection.Unit * 60 * multi
end)
script.ForwardDash:Play()
for i = 1, 30 do
multi = math.clamp(multi - .065, 0, 2)
RunService.RenderStepped:Wait()
end
if Connection then
Connection:Disconnect()
Connection = nil -- Clear the connection after usage
end
if NewBV then
NewBV:Destroy()
end
end