Dash system not working

  1. I want to achieve a dash system which is used simply to dash, Forward, Backward, Left and Right

  2. The problem is that it uses the rightVector of the humanoidRootPart which means that it will always go to the right of the humanoid rootPart. I dont want it to always do that I want it to still go left or right if the character is walking that way.

https://gyazo.com/e3a14b7adc427f0c3392222746acd8af

  1. I have tried using the camera’s lookVector unfortunately without success

LocalScript :

local player = game.Players.LocalPlayer
local Char = player.Character
local UserInputService = game:GetService("UserInputService")

local debounce = true

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E and debounce then
		debounce = false
	local HumRP = Char.HumanoidRootPart
					HumRP.Velocity = HumRP.CFrame.lookVector * 200
		wait(1.5) -- cooldown
		debounce = true
	end
end)



UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.R and debounce then
		debounce = false
		local HumRP = Char.HumanoidRootPart
		HumRP.Velocity = HumRP.CFrame.rightVector * 200
		wait(1.5) -- cooldown
		debounce = true
	end
end)

Thats just a part of the locascript.

To use the camera’s look vector as the dash direction, you need to first remove the Y component so that you only dash horizontally. So you could construct a new vector using only X and Z:

local function getHorizontalDirection(direction)
    return Vector3.new(direction.X, 0, direction.Z).Unit
end

-- Forward
HumRP.Velocity = getHorizontalDirection(camera.CFrame.LookVector) * 200
-- Backward
HumRP.Velocity = getHorizontalDirection(-camera.CFrame.LookVector) * 200
-- Right
HumRP.Velocity = getHorizontalDirection(camera.CFrame.RightVector) * 200
-- Left
HumRP.Velocity = getHorizontalDirection(-camera.CFrame.RightVector) * 200
1 Like