Wireless technology is transforming the future of transportation through the development of the Internet of Vehicles (IoV). However, intricate security challenges are intertwined with technological progress: Vehicular ad hoc Networks (VANETs), a core component of IoV, face security issues, particularly the Black Hole Attack (BHA). This malicious attack disrupts the seamless flow of data and threatens the network's overall reliability; also, BHA strategically disrupts communication pathways by dropping data packets from legitimate nodes altogether. Recognizing the importance of this challenge, we have introduced a new solution called ad hoc On-Demand Distance Vector-Reputation-based mechanism Local Outlier Factor (AODV-RL). The significance of AODV-RL lies in its unique approach: it verifies and confirms the trustworthiness of network components, providing robust protection against BHA. An additional safety layer is established by implementing the Local Outlier Factor (LOF), which detects and addresses abnormal network behaviors. Rigorous testing of our solution has revealed its remarkable ability to enhance communication in VANETs. Specifically, Our experimental results achieve message delivery ratios of up to 94.25% and minimal packet loss ratios of just 0.297%. Based on our experimental results, the proposed mechanism significantly improves VANET communication reliability and security. These results promise a more secure and dependable future for IoV, capable of transforming transportation safety and efficiency.