Never mind, I fixed it! There was no problem with the code. The problem was with the content in the BehaviorTree.