Redirecting page and reseting counter

So im having some issues with a redirect of a page. in my minigame after you mess up it takes you to an error page that lets you try again once you fail 3 times it redirects you to a different fail page that takes money away from you. The problem is that once you go to try again it no longer redirects you it just keeps letting you try again.

This is the code on the retry page that will redirect to the last fail page

<<if visited() == 3>>\
<<set $failCounter to 0>>\
<<if $failCounter < 2>>\
<<goto 'Failed'>>\
<</if>>
<</if>>

on the last fail page i have

<<if visited('faild3') == 3>>\
<<set $failCounter to 0>>\
<</if>>

it works the first time but will not work a second time upon retrying.

This if statement is saying only trigger less than 2 visits, not when equal to two visits. So you need to change it to:

<<if $failCounter <= 2>>\

or

<<if $failCounter < 3>>\

I fixed that but still same issue its not resetting the counter. I tried making a widget.

<<widget "Redirect">>
    <<set $args to $args[0]>>
       <<if visited() == 3>>
        <<set $failCounter to 0>>
        <<if $failCounter <= 3>>
    <<set $money -=50>>
    <<addTime 1>>
    <<clock "$time += 1">>
    You have Failed 3 times. Your account will be charged 50.<br>
    [[Quit|computer]]
    <</if>>
        <</if>>
            <</widget>>

however, still same results it works first time then will not reset counter so just keeps going to retry.

Post all the code where the widget “Redirect” is called and I’ll take a look

That is all the code. Rather than redirecting i tried to make it so that after three wrong answers it would give the message that they had answered wrong 3 times and lose $50 it would also advance time and add a quit button to take them back to the main computer terminal. It does all that the problem is if you go back in and lose 3 times again it wont do that again it just keeps repeating the try again.

visited() will only ever be 3 once for a given passage. It is not a story variable and can never be reset. So try using a story variable instead of visited(), increment it on a fail, then set it back to 0 after the player quits and goes back to the main terminal.

I tried making a variable in storyinit. no clue if i did it right. im still new to all this.

<<set $visitFailE to visited("failed3")>>

cant get it to work unless i use the visited()