How do I make an object float using script?

Hi developers,
I am trying to make a floating vehicle but the way I’m doing it doesn’t seem efficient and as you can see it’s not smooth and it’s keep going up and down, I’ve searched for tutorials but I can’t find a proper way to do it.

Do you have any suggestions on how I can make that possible?
Thank you.

The script I used:

local part = script.Parent
local seat = script.Parent.Parent.VehicleSeat
local rayToGround = Ray.new(part.Position, Vector3.new(0,-10,0))

local testpart = Instance.new("Part", workspace)
testpart.Name = "testPart"

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
    if seat.Occupant ~= nil then
        while wait(0.05) do
            local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(rayToGround, {part})
            if hit then
                local rayDistanceToGround = part.Position.Y - position.Y
                print(rayDistanceToGround)
                if rayDistanceToGround < 1 then
                    part.Velocity = Vector3.new(0,9,0)
                end
            end
        end
    end
end)

Here is the result:

What does the output say? I’m wondering if it’s something to do with the raycast. Also if you want it to be smoother you could always use Tweenservice.

The output shows the distance to the ground which is something between 0 and 2 unless I make a big change in Y axis. also I want to be able to move this object around so I’m pretty certain I cannot use TweenService since it does not work with unanchored objects (or if it does its very laggy)

Maybe it is going down because it is unanchored.