Since you are cycling up and down, you need to remember state as well as use comparator to determine direction you should be counting. Here is one solution:
Since the flip-flop is going to default to false and count defaults to zero, we want false to be our “count up” state, so our count-STEP is 1 when flip-flop-MEM is false. When we get to our max (5), we want to trigger flip-flop-SET, which will change count-STEP to -1, so we will now count down until we get to our min (0) and we trigger flip-flop-RST, changing count-STEP back to 1 so we are counting up again.
I only use greater-or-equal and less-or-equal instead of equal because technically count is using floating point numbers, and there is a chance for rounding errors to cause count to become something like 0.000000001, which is NOT equal to zero. It is a simple fail-safe to add to your programs so you don’t accidentally run past where you want to stop; the worst-case is now that you will go to -1 or 6 before changing direction rather than running to infinity (or in this case an error because the float value over-flows–the value becoming too small/big to store).
NOTE: since the count node does not provide a way to start at any number besides 0, counting from 1 to 5 instead of 0-5 becomes difficult. Probably the easiest solution is to let the count node count between 0 and 4, then add 1 to the output of count to get 1-5. The same technique can be used to count -5 to 5, or any other range. You can also use it to reverse directions; for example, if you wanted to start at 5, count down to 0, then back up to 5, you can use the code above, but subtract count output from 5. The 1st number would be 5-0=5, then 5-1=4, etc.