How to make Linear velocity without "knockback"

I made a dash using linear velocity but if I dash against an anchored object the player will get a big knockback, I tried to anchor the character but the linear velocity doesn’t work very well on that way.

if necessary here’s my script:

local tool =  script.Parent
local Player = game:GetService("Players").LocalPlayer
local ContextActionSerice = game:GetService("ContextActionService")
local char = Player.Character
local Humrp  = char:WaitForChild("HumanoidRootPart",6)

local isAttacking =  false
local Mouse = Player:GetMouse()
local Uis = game:GetService("UserInputService")
local Debris = game:GetService("Debris")
local Hum = char:WaitForChild("Humanoid",6)
local Maxforce = Vector3.new(math.huge,math.huge,math.huge)
local amt = nil
local Cooldown = false
local notequip = true
--local DashVelocity = Humrp.CFrame.lookVector

                  --Script--
function Attack1()
	
	if Humrp.Parent.Humanoid.FloorMaterial == Enum.Material.Air or Cooldown or notequip
	then return end
	
	if Cooldown == true then print("OnCooldown") task.wait(2) Cooldown = false return end
	
	Cooldown = true
	print("Used")

	local lv = Instance.new("LinearVelocity")
	local Ani = Instance.new("Animation")
	Ani.Parent = Hum
	Ani.AnimationId = "rbxassetid://11182501695"
	local Animator = Hum:FindFirstChild("Animator")
	local animation = Animator:LoadAnimation(Ani)
	animation:Play()
	lv.Parent = Humrp
	local dashtime =  .2
	local speed = 100
    local Humrpatt = Humrp:FindFirstChild("RootRigAttachment")
	lv.MaxForce = math.huge
	lv.Attachment0 = Humrp:FindFirstChild("RootRigAttachment")
	local lookv = Vector3.new(Humrp.CFrame.LookVector.X*speed,0,Humrp.CFrame.LookVector.Z*speed)
	lv.VectorVelocity = lookv
	
	task.wait(dashtime)
	lv:Destroy()

	
    task.wait(dashtime*2)
	animation:Stop()
	
	task.wait(2)
	Cooldown = false
	
end

tool.Equipped:Connect(function()
	notequip = false
end)
tool.Unequipped:Connect(function()
	notequip = true
end)



ContextActionSerice:BindAction("Attack",Attack1,true,Enum.KeyCode.Z)

1 Like

instead of using math.huge use 10e5 as the value for maxforce, that’s what I use and it lessens the “knockback”. I’m pretty much at a beginner level when it comes to the studio so sorry if this wasn’t helpful.

1 Like

I found a solution with this script

local connection
connection = char.Hitbox.Touched:Connect(function(part)  -- make hitbox whatever part for collisions
	if part ~= workspace:FindFirstChild("Baseplate") then
		if humrp.Position.Y < part.Position.Y + part.Size.Y/2 then
			V:Destroy()   --destroy velocity 
		end
	end
end)

by @Ilove_COMUNISM

2 Likes

awesome! also, thanks for the info ill try it out!