Setting 2D Screen Boundaires

I have tried but unsuccessfully to create a C# script to limit my player from moving outside the camera’s view port. I only need this to work for the width of the screen as it is an infinite runner based game. Any help would be greatly appreciated, thank you!

This should be what you need.