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)