I am making a dash system where the player presses a button and moves him forward, but when the player dashes on the edge of something he gets boosted (he moves forward more than he should).
I tried two things but none of them work:
-- get the loock vector
local hrp = script.Parent.HumanoidRootPart
local p1 = hrp.Position
wait(0.05)
local lookVector = CFrame.new(p1, hrp.Position).LookVector
-- way 1:
self.hrp.Velocity = self.DashSpeed*(lookVector * Vector3.new(1,0,1)).unit;
-- way 2:
local BV = Instance.new("BodyVelocity")
BV.MaxForce = Vector3.new(5e4, 5e2, 5e4)
BV.Velocity = lookVector * 200
BV.Parent = hrp
game.Debris:AddItem(BV, 0.2)