How to stop players from getting out of a vehicle if there is a part blocking the exit?

The title of the topic explains it all, but here is an example of what I am talking about:

car

I have small parts on each side of the car (where the player teleports out of the car). However, sometimes if there is a part on the side of the car, the player gets stuck.

What is the best way to fix this problem?

Code:

local function SitPlayerInSeat(Seats)	
	Seats.Part.ProximityPrompt.Triggered:Connect(function(Player)
		if Seats.Occupant then return end
		
		if Player then 
		--	local NameTag = Player.Character.Head:WaitForChild("NameTag")
			local Humanoid = Player.Character:FindFirstChild("Humanoid")
			if Humanoid then
				Seats:Sit(Humanoid)
				Seats.Part.ProximityPrompt.Enabled = false 
			--	NameTag.Enabled = false
				
				RemoveAccessorys(Player)
				
				local SeatConnection 
				SeatConnection = Seats:GetPropertyChangedSignal("Occupant"):Connect(function()	
					Seats.Part.ProximityPrompt.Enabled = true
				--	NameTag.Enabled = true
					
					wait(0.1)
					if Seats.Name == "FR" or Seats.Name == "BR" or Seats.Name == "Middle" then
						Player.Character.HumanoidRootPart.CFrame = Seats.Parent.RightSide.CFrame
					elseif Seats.Name == "BL" then
						Player.Character.HumanoidRootPart.CFrame = Seats.Parent.LeftSide.CFrame
					elseif Seats.Name == "DriveSeat" then
						Player.Character.HumanoidRootPart.CFrame = Seats.Parent.Body.LeftSide.CFrame
					end
					
					AddAccessorys(Player)
					
					SeatConnection:Disconnect()
				end)
			end
		end
	end)
end

local function GetAllSeats()
	for _, Seats in pairs(CollectionService:GetTagged(Seats_Tag)) do 
		SitPlayerInSeat(Seats)
	end
end

GetAllSeats()

Cast a ray from the position of the player in the car to the position the player teleports to outside the car. If there is a hit, then you’ll know not to get out.
I’m not the best with raycasting, so here’s an article if you need more help: