Better way to tell whether car is on the ground?

I’m currently creating a fully custom car, and I am hoping to tell whether the car is in the air or not as I don’t want it to glitch a bit in the air. I currently have

local touchingparts = {
	[script.Parent.WheelFL] = script.Parent.WheelFL:GetTouchingParts(),
	[script.Parent.WheelFR] = script.Parent.WheelFR:GetTouchingParts(),
	[script.Parent.WheelBL] =  script.Parent.WheelBL:GetTouchingParts(),
	[script.Parent.WheelBR] = script.Parent.WheelBR:GetTouchingParts()
}

local inair = true

for wheel, parts in pairs(touchingparts) do
	for i, part in pairs(parts) do
		if part.CFrame.Position.Y < wheel.CFrame.Position.Y and not part.Parent:FindFirstChild("Humanoid") then
			local touchingother = false
			
			for wheel2, parts2 in pairs(touchingparts) do
				if wheel2 ~= wheel and table.find(parts2, part) then
					touchingother = true
				end
			end
			
			if touchingparts then
				inair = false
			end
		end
	end
end

This doesn’t cause any errors but also doesn’t always detect properly. Is there a better way to go about this and tell whether it is on the ground properly? Here is a video of the problem:


And yes, I have tried using raycasting from the body downward, which was also causing problems on ramps.

you can put a script in the tires and put

local tires = YourTires 

tires.Touched:Connect(function()
--Code goes here

That’s not the problem, I am getting all of the parts touching the tires, which should include the ramp too.

Like the car is glitching because it is touching the parts/ground?

No, the car seems to not be detecting that multiple wheels are touching the ramp itself. Other than on the ramp, there doesn’t seem to be much problem.

Pardon for me being ignorant, but what is your problem again?

The car is not able to go up the ramp without being considered “in the air”, causing the car to stop moving.

I believe I have solved the issue. I switched back over to raycasting downward and it detects better, but it also had to do with the fact that I was raycasting in front of the car as well to make sure that there was no wall in front of the car. I had to check whether the object under the car isn’t equal to the object in front to fix going up the ramp.

Great Job. Have a good day/night