How to make X "relative"

So, i have this normal angle

local NormalAngle = math.acos(Normal:Dot(Hoverboard.PrimaryPart.CFrame.UpVector)) * 3

And it does quite work untill you go reverse, and that’s because i’m adding it onto the X axis like this

CFrame.Angles(NormalAngle,math.rad(90),0)

So, does anyone know how i could make it relative to the board?
The raycast is firing downwards from the hoverboard btw.


Does anyone know how i could make the normal relative to the board too?

You mean orient to surface normal? Quaternions are your best bet, though really it’s just 3d rotation from one vector to another vector.

Ok well, would this work with me adding the normal angle onto the hoverboard? as that’s mainly what i’m doing.

Hoverboard.PrimaryPart.BodyGyro.CFrame = LastUpdatedAngle * CFrame.Angles(0,math.rad(90),0) + getRotationBetween(Hoverboard.PrimaryPart.CFrame.UpVector,Normal,Vector3.new(1,0,0)).Rotation

Simply construct a rotation matrix out of the surface normal as an upVector:

local up = surfaceNormal -- fill this in
local fwd = -Hoverboard.PrimaryPart.CFrame.LookVector * Vector3.new(1, 0, 1)
local right = up:Cross(fwd)

Hoverboard.PrimaryPart.CFrame = CFrame.fromMatrix(Hoverboard.PrimaryPart.CFrame.Position, right, up, fwd)