I’m trying to make a dash system using BodyVelocity, but when the character dashes into a wall, they get fling
local dashing = Instance.new("BoolValue")
dashing.Name = "Dashing"
dashing.Parent = StatusFolder
local dashEndlag = Instance.new("BoolValue")
dashEndlag.Name = "DashEndlag"
dashEndlag.Parent = StatusFolder
Debris:AddItem(dashEndlag, .35)
Debris:AddItem(dashing, .35)
local dashVelocity = Instance.new("BodyVelocity")
dashVelocity.MaxForce = Vector3.new(999999,0,999999)
dashVelocity.Parent = Character.HumanoidRootPart
local dashConnection = nil
dashConnection = RunService.RenderStepped:Connect(function()
if not dashing.Parent then
dashConnection:Disconnect()
dashConnection = nil
dashVelocity:Destroy()
local dashCooldown = Instance.new("BoolValue")
dashCooldown.Name = "DashCooldown"
dashCooldown.Parent = StatusFolder
Debris:AddItem(dashCooldown, .25)
return
end
if direction == "Left" then
dashVelocity.Velocity = Character.HumanoidRootPart.CFrame.RightVector*-70
elseif direction == "Right" then
dashVelocity.Velocity = Character.HumanoidRootPart.CFrame.RightVector*70
elseif direction == "Forward" then
dashVelocity.Velocity = Character.HumanoidRootPart.CFrame.LookVector*70
elseif direction == "Back" then
dashVelocity.Velocity = Character.HumanoidRootPart.CFrame.LookVector*-70
end