The Prophet ﷺ said, "Leave me alone as long as I leave you alone. Those before you were destroyed only because of their excessive questioning and their disagreements with their prophets. So when I forbid you from something, avoid it, and when I command you to do something, do as much of it as you are able."
عن النبي ﷺ قال: دعوني ما تركتكم، إنما هلك من كان قبلكم بسؤالهم واختلافهم على أنبيائهم، فإذا نهيتكم عن شيء فاجتنبوه، وإذا أمرتكم بأمر فأتوا منه ما استطعتم.
Bukhari narrated it in the Book of Holding Fast (7288), and Muslim in the Book of Virtues (1337: 131), both of them through Abu Zinad, from Araj, from Abu Hurairah, who said, and then he mentioned it. The wording given here is Bukhari's.