D&D Collision Issue


I'm not even sure if I'm posting in the right place, this being my first post, but, I do not know how to solve an issue I am having with my game. I would really appreciate any help.

I want to make my player object restart the game if it collides with a certain object if the space bar is NOT pressed. If it IS pressed, however, I want a special animation to play and for the object to continue moving. I will attach the current D&D code I have via screenshot.

So far, essentially, I made the variable "Leap" for when I want my character to "Leap" over obj_block2. If Leap = 0, it will play my character's idle animation(spr_player). But if vk_space is pressed, and if Leap is less than or equal to 0, and if obj_block2 is colliding with my current x,y, coordinate, my leap animation plays. I set it so I can only leap when obj_block2 is colliding with my current x and y coordinate. (Ideally I want to make it so I can leap a few frames before I really collide, but that's another story).

Now, however, I want to make it so that if I DON'T press vk_space, the game restarts. If I DO press it, it doesn't restart and I continue playing. I tried attaching Else statements to the vk_space If statement in the screenshot, but all that does is it makes me restart the game as soon as I touch obj_block2, essentially not giving me enough time to press vk_space and do my animation. I don't know what to do. I sincerely apologize if I'm not being very specific. Please let me know if you need more info. Any and all help is appreciated. Screenshot (1).png


I don't see code there where it shows it will restart, is there other code you can show us?

You may want to look at alarms. Once you collide, you trigger an alarm equal to however many frames you want to delay the restart, giving you enough time to hit the space key. In that alarm routine, you put the code that restarts. That code will only run once the alarm reaches 0 (it counts backwards).

Now you have to be careful, you need some variable as a flag that you set to true once collided. Only check the collision if that flag is false. This is so the alarm doesn't keep getting reset while you're still colliding, causing the alarm to never reach 0. Once the alarm sets off, or once you are no longer colliding, reset that flag back to false.

Hopefully that helps