Hello. I would like to know if anybody could help with this predicament I am having. This code works as intended, but only goes in the X direction. I know why it does, so you don't need to explain that to me, so I just want to know how to make this sort of BodyVelocity multi-directional depending on the direction the player is facing. (This is supposed to be a diving feature, sorta like in Super Mario 64)

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Root = Character:WaitForChild("HumanoidRootPart")
local rs = game:GetService("RunService")
local bodyVelocity = Instance.new("BodyVelocity", Root)
local diving = 0
bodyVelocity.Velocity = Vector3.new(50,20,0)
bodyVelocity.MaxForce = Vector3.new(0,0,0)
	
-- ===================== ANIMATIONS ==============================
local diveanimation = Instance.new("Animation")
diveanimation.AnimationId = "rbxassetid://5681784979"
local diveanim = Humanoid:LoadAnimation(diveanimation)
diveanim.Priority = 2
--
local divinganimation = Instance.new("Animation")
divinganimation.AnimationId = "rbxassetid://6342016944"
local divinganim = Humanoid:LoadAnimation(divinganimation)
divinganim.Priority = 2
--
local divecancelanimation = Instance.new("Animation")
divecancelanimation.AnimationId = "rbxassetid://6342024942"
local divecancelanim = Humanoid:LoadAnimation(divecancelanimation)
divecancelanim.Priority = 2



local function DiveAnimate()
	diveanim:Play()
	wait(0.25)
	divinganim:Play()
end



-- ===================== ACTIVATION SCRIPTS ==============================
game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.LeftShift and diving == 0 and Humanoid.FloorMaterial == Enum.Material.Air then 
		print ("Dive!")
		bodyVelocity.MaxForce = Vector3.new(8000,8000,8000)
		wait(0.1)
		bodyVelocity.MaxForce = Vector3.new(8000,0,8000)
		Humanoid.MaxSlopeAngle = 5
		Humanoid.JumpPower = 30
		Humanoid.WalkSpeed = 0
		diving = 1
		DiveAnimate()
	elseif inputObject.KeyCode == Enum.KeyCode.Space and diving == 2 and Humanoid.FloorMaterial ~= Enum.Material.Air then
		wait(0.1)
		print ("Canceled dive!")
		divinganim:Stop()
		diveanim:Stop()
		bodyVelocity.MaxForce = Vector3.new(0,0,0)
		Humanoid.JumpPower = 60     
		Humanoid.MaxSlopeAngle = 50
		Humanoid.WalkSpeed = 30
		diving = 0
		divecancelanim:Play()
		divecancelanim:AdjustSpeed(2)

	end 
end)

Humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
	if Humanoid.FloorMaterial ~= Enum.Material.Air and diving == 1 then
		print ("Hit ground!")
		bodyVelocity.MaxForce = Vector3.new(0,0,0)
		Humanoid.WalkSpeed = 0
		Humanoid.JumpPower = 35
		diving = 2
	end
end)


(sorry for the messy code lol)