I’m trying to make a dashing function and last time I’ve done dashing I used body velocity, however, that seems to have been replaced by linear velocity which I can’t figure out how to use I had thought it would be the same, but seems to be a little bit different.
I made this rough code using a devfourm post I found and it works except the linear velocity doesn’t do anything.
-- Input Hnalder
UIS.InputBegan:Connect(function(input,gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.W then
local currentTime = tick()
if currentTime - lastPress <= EXIT_THRESHOLD then
print("Double Pressed W")
player:Dash()
else
lastPress = currentTime
end
end
end)
-- Base Character Class
function BaseCharacter:Dash()
local function GetRelativeDirection(direction, relativeTo)
return CFrame.lookAt(relativeTo.Position, (relativeTo.Position + direction)).LookVector
end
local hrp = self.model:WaitForChild("HumanoidRootPart")
local humanoid = self.model:WaitForChild("Humanoid")
local lv = Instance.new("LinearVelocity")
local direction = humanoid.MoveDirection
local cam = workspace.CurrentCamera
local dashVelocity = 80
local duration = 0.12
local relativeDirection = GetRelativeDirection(direction, cam.CFrame)
if direction.Magnitude == 0 then
direction = hrp.CFrame.LookVector
end
lv.VectorVelocity = Vector3.new(30,0,0)
lv.MaxForce = 50000
lv.Parent = hrp
game.Debris:AddItem(lv,duration)
end