Communication between mobile nodes occurs in mobile ad hoc networks without a centralized control system. The mobility of a node in this environment is unpredictable; this is a feature of wireless networks. The network is subject to routing misbehaviour and attacks as a result of defective or malicious nodes. Active attacks are the most harmful for networks because they raise the risk of information loss. The focus of this research is on the Black Hole Attack. This assault degrades the MANETs' performance to the point where regaining control becomes the most difficult task. Several researchers previously worked to combat these assaults, but the problem persists, compromising the network with numerous dangers. Most suggested security methods have not been tested on huge amounts of traffic, attacker nodes, or congestion, which increases the complexity of communication and necessitates the development of preventative techniques. As a result, in this paper, a trust-based security protocol is proposed. The trust parameters, which are derived based on two factors: (i) Current Energy and (ii) Packed Drop Count of a node, are used to choose IDS. The selected IDS node assists the source node in selecting a data transmission path and then monitoring that route until the transmission is complete. The impact of each scenario is computed using PDR, NRL, and PLR, and the performance of this proposed protocol is tested using three distinct scenarios with varied numbers of attackers, mobility, and nodes. In order to assess the effectiveness of this work, a grey hole attack is used. The average PDR is 97.7%, the NRL is 1.157, and the PLR is 2.22%, which is higher than other current protocols such as Reputation Value and AODV. In this work, a comparison is conducted for each scenario, and it is noticed that increasing the number of attackers and mobility decreases performance, but increasing the number of nodes increases the possibility of more alternative pathways. All of the calculations demonstrate that the proposed protocol outperforms other current protocols, achieving the intended result.