LinearVelocity/BodyVelocity flings player when running into a wall or part

Hi, so i’ve made a dash move and roll move for my character. They both work fine, but the problem is that whenever you run into a wall while dashing or rolling, the player will go crazy and twitch everywhere as you can see in the video. The rolling also sometimes clips into the floor and twitches everywhere, basically what happens in the video but with the floor instead. Please help!

I’ve already tried disabling the Humanoid Ragdoll and FallingDown states, but it won’t work.

if self._Humanoid:GetState() == Enum.HumanoidStateType.Freefall and not self._Root.Anchored and self._Humanoid.MoveDirection.Magnitude > 0.5 and not Tramping and not Bolting and not Drifting and not Recoiling then
        Bolting = true
        BoltAnim:Play(0, 20, 1)
        self._Expressions:Swap("Sad", "Right")
        --------------------------------------
        local Sound = Sounds.Player.BoltSound:Clone()
        Sound.Parent = self._Root
        Sound.PlaybackSpeed = math.random(9,10)/10
        Sound:Play()
        Debris:AddItem(Sound, 1.5)
        --------------------------------------
        local Attachment = Instance.new("Attachment", self._Root)
        Attachment.Position = Vector3.new(0, 0, 0)
        Attachment.Name = "BoltAttachment"
        --------------------------------------
        local Direction = self._Root.CFrame.LookVector
        local Velocity = Instance.new("LinearVelocity", self._Root)
        Velocity.Name = "BoltVelocity"
        Velocity.VectorVelocity = Direction * 80
        Velocity.Attachment0 = Attachment
        Velocity.MaxForce = math.huge
        --------------------------------------
        Debris:AddItem(Attachment, 0.25)
        Debris:AddItem(Velocity, 0.25)
        --------------------------------------
        local Effect = Effects.Player.BoltEffect:Clone()
        Effect.Parent = workspace
        Effect.Position = self._Root.Position
        Effect.Orientation = self._Root.Orientation - Vector3.new(0, 0, 90)
        local TweenInform = TweenInfo.new(0.25, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
        local TweenEffectSize = TweenService:Create(Effect, TweenInform, {Size = Vector3.new(8, 8, 0.1)})
        local TweenEffectTransparency1 = TweenService:Create(Effect.Front.ImageLabel, TweenInform, {ImageTransparency = 1})
        local TweenEffectTransparency2 = TweenService:Create(Effect.Back.ImageLabel, TweenInform, {ImageTransparency = 1})
        TweenEffectSize:Play()
        TweenEffectTransparency1:Play()
        TweenEffectTransparency2:Play()
        --------------------------------------
        Debris:AddItem(Effect, 0.5)
        --------------------------------------
        task.wait(.5)
        --------------------------------------
        Bolting = false
    elseif self._Humanoid:GetState() == Enum.HumanoidStateType.Running and not self._Root.Anchored and not Reeling then
        Reeling = true
        ReelAnim:Play(0.25)
        --------------------------------------
        --[[local Sound1 = Sounds.Player.ThrustSound:Clone()
        Sound1.Parent = self._Root
        Sound1:Play()
        local TweenSound0 = TweenService:Create(Sound1, TweenInfo.new(0.125), {Volume = 0})
        local TweenSound1 = TweenService:Create(Sound1, TweenInfo.new(0.125), {Volume = 0.25})
        --------------------------------------
        spawn(function()
            while Reeling do
                if math.round(self._Humanoid.MoveDirection.X) == -1 or math.round(self._Humanoid.MoveDirection.X) == 1 and math.round(self._Humanoid.MoveDirection.Z) == -1  then
                    TweenSound1:Play()
                else
                    TweenSound0:Play()
                end
                task.wait()
            end
        end)]]
        --------------------------------------
        local Sound2 = Sounds.Player.ReelingSound:Clone()
        Sound2.Parent = self._Root
        Sound2:Play()
        --------------------------------------
        local Velocity = Instance.new("BodyVelocity", self._Root)
        Velocity.Name = "ReelVelocity"
        Velocity.P = 5000
        Velocity.MaxForce = Vector3.new(1e8, 1e8, 1e8)
        Velocity.Velocity = self._Root.CFrame.LookVector * 60
        --------------------------------------
        local Effect = Effects.Player.ReelParticles:Clone()
        Effect.Parent = self._Root.EffectPos
        --------------------------------------
        spawn(function()
            while Velocity do
                Velocity.Velocity = self._Root.CFrame.LookVector * 60
                task.wait()
            end
        end)
        --------------------------------------
        --Debris:AddItem(Sound1, 2)
        Debris:AddItem(Sound2, 2)
        Debris:AddItem(Velocity, 2)
        Debris:AddItem(Effect, 2)
        --------------------------------------
        task.wait(2)
        --------------------------------------
        Reeling = false
        ReelAnim:Stop()
    else
        return

Maybe try increaseing the mass of the character? I’m not too sure about this, I don’t have experience on BodyVelocities.

Just tried it, it didn’t work sadly.

Very clean looking code, good job.

1 Like

Thanks, i always make sure to keep my coding clean and tidy. + Object Oriented Programming helps with making everything organized!