How can I make a hoverboard with align position and align orientation

I’m trying to make a hoverboard using align position and align orientation my current plan/idea is to have a part that will rotate based on input which will then control the orientation (with align orientation) of the hoverboard and then a ray shooting down from the hoverboard and then lowering it based on the distance (with align position)

It very clearly doesn’t work, but it did somewhat do what I was trying to do so perhaps I’m on the right track?


(very rough code)

HoverboardComponent.Started:Connect(function(component)
	local instance = component.Instance
	
	local params = RaycastParams.new()
	
	params.FilterDescendantsInstances = {}
	params.FilterType = Enum.RaycastFilterType.Blacklist
	params.IgnoreWater = true
	
	local ap = instance.AlignPosition

	RunService.Stepped:Connect(function(dt)
		local origin = instance.Position
		local direction = -(instance.CFrame.UpVector) * 20
		local result = workspace:Raycast(origin, direction, params)
		if result then
			VisualizeRay(origin,result,result.Position)
			local distance = (instance.Position - result.Position).Magnitude
			ap.Position = result.Position -- trying to lower the part to the surface
		end		
	end)
end)

Align position and align orientation aren’t the right ways to make a hoverboard. I suggest using a script that will increase vertical force based on distance.

Aw I was about to say what SubtotalAnt said

Anyways I would recommend you change the hoverboard’s CFrame according to the ray.Normal to align it. You would probably need to offset the Y Position too. And to make the hoverboard hover you would need to script what SubtotalAnt mentioned.

Here’s what your align code might look like:

yourhoverboardPart.CFrame = CFrame.new(result.Position, result.Position + ray.Normal)
-- result.Normal orientates the part depending on the side it faces

Here’s what your hover code might look like:

local dist = (origin - result.Position).Magnitude

vectorForce.Force = Vector3.new(0,dist* game.Workspace.Gravity,0)
-- Not sure if the * workspace.Gravity will work but you should get the idea

If you have any questions let me know @Konjointed