Hey, I believe you can do something like:
--If condition met (I'm assuming you don't always want the player stuck in a box)
--every tick
-----------Player -> set x to clamp(player.x,camera.x-(window.width/2),camera.x+(window.width/2))
I'm away from home so I can't test it but I think that should work. If not I'll to make an example when I get a moment.