# How to apply vector forces in the correct direction?

Here is the code I use to control the forwards force on a hoverboard I am working on:

``````local rotation = CFrame.Angles(0, math.rad(90), 0)
local forceDirection = (hrp.CFrame * rotation).LookVector.unit
print("Force Direction: ", forceDirection)

local cosAngleX = forceDirection:Dot(Vector3.new(1, 0, 0))

cosAngleX = math.clamp(cosAngleX, -1, 1)

local angleX = math.acos(cosAngleX)
print("Angle X: ", math.deg(angleX))

local scalingFactorX = math.cos(angleX)
local scalingFactorY = math.sin(angleX)
print("Scaling Factors: ", scalingFactorX, scalingFactorY)

force.Force = Vector3.new(speed * math.abs(scalingFactorX), 0, speed * math.abs(scalingFactorY))
``````

The rotation accounts for the player being sideways on the board. This code is about 75% successful. It properly calculates both Scaling factors, and applies force correctly in the x direction. The Y direction is wrong however, and when attempting to travel on the y axis(z axis in the world) , the board will move along the x axis instead.