Make a dash based on players screen

so i wanted to revamp my dash script a lil bit because sometimes its not accurate and i thought about basing the dash on the middle point of ur screen then adding some values to change the x and z but idk how to convert it to 2d to 3d

Dash.OnServerEvent:Connect(function(player,DashKey)
	local HumanoidRootPart = player.Character:WaitForChild("HumanoidRootPart")
	local dashvelocity = Instance.new("BodyVelocity")
	local randomnumber = math.random(1,3)
	
	DrainStamina:Fire(player,15)
	
	dashvelocity.P = 1000
	dashvelocity.MaxForce = Vector3.new(100000,0,100000)
	dashvelocity.Parent = HumanoidRootPart
	
	if DashKey == "W" then
		dashvelocity.Velocity = HumanoidRootPart.CFrame.LookVector * 75
		dashvfx(randomnumber,player,"W")
	elseif DashKey == "A" then
		dashvelocity.Velocity = HumanoidRootPart.CFrame.RightVector * -75
		sidedashvfx(randomnumber,player,"A")
	elseif DashKey == "S" then
		dashvelocity.Velocity = HumanoidRootPart.CFrame.LookVector * -75
		dashvfx(randomnumber,player,"S")
	elseif DashKey == "D" then
		dashvelocity.Velocity = HumanoidRootPart.CFrame.RightVector * 75
		sidedashvfx(randomnumber,player,"D")
	end
	
	Debris:AddItem(dashvelocity,0.15)
end)

if u know anything lmk

Use the Camera CFrame lookVector

dashvelocity.Velocity = camera.CFrame.LookVector * 75

However, this will also aim upwards and downwards. If you just want to go left or right, then do not use the Y vector.

local direction = camera.CFrame.LookVector
dashvelocity.Velocity = Vector3.new(direction.X, 0, direction.Z)
Dash.OnServerEvent:Connect(function(player,DashKey)
	local currentcamera = game:GetService("Workspace").CurrentCamera
	local HumanoidRootPart = player.Character:WaitForChild("HumanoidRootPart")
	local dashvelocity = Instance.new("BodyPosition")
	local randomnumber = math.random(1,3)
	
	DrainStamina:Fire(player,15)
	
	dashvelocity.P = 5000
	dashvelocity.MaxForce = Vector3.new(600000,0,600000)
	dashvelocity.Parent = HumanoidRootPart
	
	if DashKey == "W" then
		dashvelocity.Position = currentcamera.CFrame.LookVector + Vector3.new(0,0,-45)
		dashvfx(randomnumber,player,"W")
	elseif DashKey == "A" then
		dashvelocity.Position = (HumanoidRootPart.CFrame * CFrame.new(-45,0,0)).Position
		sidedashvfx(randomnumber,player,"A")
	elseif DashKey == "S" then
		dashvelocity.Position = (HumanoidRootPart.CFrame * CFrame.new(0,0,45)).Position
		dashvfx(randomnumber,player,"S")
	elseif DashKey == "D" then
		dashvelocity.Position = (HumanoidRootPart.CFrame * CFrame.new(45,0,0)).Position
		sidedashvfx(randomnumber,player,"D")
	end
	
	Debris:AddItem(dashvelocity,0.10)
end)

i tried to test smth out cuz sometimes my dashes go in unexpected directions but when i press w it just goes in 1 direction no matter where im facing?