$6$ right angles can be achieved, as in the diagram below:

If there were seven right angles, these would be a total of $7 \times 90^\circ = 630^\circ$. The total interior angle of an octagon is $6 \times 180^\circ = 1080^\circ$, so the final angle would have to be $1080^\circ - 630^\circ = 450^\circ$. The interior angle cannot be more than $360^\circ$, so this cannot be achieved.

*This problem is taken from the UKMT Mathematical Challenges.*

View the current weekly problem