How to prevent an object from walking backward?

Hi,

This is a simple question, it is probably also quite nooby. I have a gameobject randomly moving around. How would I prevent it from moving backwards.

I don’t want any answers featuring ‘remove the code for walking backwards’. All I need to know is how to detect the object moving backwards and stop it.

Thank You,

post the code