How do I align with slopes properly?

I’m creating a skateboard and was trying to make going up slopes, the problem I found with the script i’m using is that steeper slopes have bug out my character, and my goal was to ride in a loop.

Code:

local char = script.Parent
local rootPart = char:WaitForChild("HumanoidRootPart")
local xzGyro = Instance.new("BodyGyro")
local yGyro = Instance.new("BodyGyro")
yGyro.MaxTorque = Vector3.new(0,3e5,0)
yGyro.P = 5e5
xzGyro.MaxTorque = Vector3.new(3e5,0,3e5)
xzGyro.P = 5e5
xzGyro.Parent = rootPart

game:GetService("RunService").Heartbeat:Connect(function()
	local params = RaycastParams.new()
	params.FilterDescendantsInstances = {char}
	params.FilterType = Enum.RaycastFilterType.Exclude
	local result = workspace:Raycast(rootPart.Position, Vector3.new(0,-10,0), params)

	yGyro.CFrame = CFrame.new(rootPart.Position, rootPart.Position + char.Humanoid.MoveDirection*10)

	if (result) then
		print(result.Normal)
		local currentRightVector = rootPart.CFrame.RightVector
		local upVector = result.Normal
		local newFacialVector = currentRightVector:Cross(upVector)
		--xzGyro.CFrame = CFrame.fromMatrix(rootPart.Position, currentRightVector, upVector, newFacialVector)
		game:GetService("TweenService"):Create(xzGyro, TweenInfo.new(.1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {CFrame = CFrame.fromMatrix(rootPart.Position, currentRightVector, upVector, newFacialVector)}):Play()
	end

end)

Video:

(Context: Skateboard is welded to my character with custom properties and uses animations primarily. I use movers like alignorientation for rotating my character and bodyvelocity to move)

image

What if you just raycast straight down on each set of wheels and then position in the middle of each intersection?

You can use the surface normal and the RightVector component of the characters CFrame to get the LookVector and making a CFrame matrix with which you can get the individual components of that CFrame.