# Attack/Rest alternating cycle

Hi, I’m not very intelligent but my dream is making a simple game.
I will try to explain what I want to accomplish here:

1)There are life points that the player can click on to decrease them
2) There is a timer that resets to 10 every time it reaches 0
3) I’d like the player to be able to click on the points and decrease them for 1 cycle during the 10 seconds and not to be allowed to decrease the points in the next cycle and so on…
4) I added a boolean and it kind of works 1 time but then you can still decrease the life points, no alternation as you can see.

Hi, looks like your boolean value is set to false only once at the beginning of the scene. Shouldn’t be set to false when you click on lifescreen?
At the beginning of the scene (only condition) you just need to set it to true and start the timer.

1 Like

sorry I tried doing what you suggested and it is not working.

Honestly I have no idea how to achieve what I want, I’m so confused

well I’m thankful for your response but the code you presented doesn’t accomplish what I was trying to do.
When I write your code on my project what it does is: every time it reaches ten it allows you decrease just one point. That’s not what I meant. What I meant was the player is allowed to decrease points for a whole cycle of ten seconds and then rest for another cycle of ten seconds and so on.

I’m still very confused as to how one would accomplish that

Ah, apologies, I reread you initial post, and realise I skipped step 3.

In that case, instead of setting the boolean in the last event, use “`Toggle the boolean value of attackTrue`

1 Like

Oh ok I understand what you mean. Then you could say:
if timer >=10, set boolean to false
If timer >=20, set boolean to true and reset timer.

1 Like

Wow yes! Both of you gave me a good solution. I am going to go with MrMen’s solution because I never realised there is an actual toggle boolean function. I’m incredibly bad at this but learning thanks to you guys.

2 Likes

Great! I’ve never used boolean variables, so I’ve learnt too!

2 Likes