Help with game. will explain in post

I want the player to die once the broken heart hits the white rectangle but the player dies instantly once the gameplay frame loads. Help me. I dunno what to do. so just repair the file and give it to me.
Project

var die = gotoAndPlay(3);

that’s the problem. you call gotoAndPlay. and gotoAndPlay makes you go to frame 3. and this is in the default script. also gotoAndPlay and gotoAndStop doesn’t return anything. so if (heart.gotoAndStop(2)) is not valid.

also it should be this.die instead because if you just say die then you can only use the die variable in the same context it was created (that is the Default script). if you use the die variable anywhere else it either won’t work or make another variable.

also i don’t know what the die variable is supposed to be anyway? what is it supposed to mean? because you (tried) initiliaize the variable to be 3, pointing to frame 3? but in the update script it’s whether the heart is dead or not?

Also i really don’t know why you thought it’d be OK to use gotoAndPlay and gotoAndStop that way???

2 Likes

Another issue (haven’t looked in the code, just guessing) is that the player doesn’t have invincibility frames. Basically, look at it like this.

Let’s say that big Mario runs into a goomba. Mario takes damage and becomes small again. He has damage boost because he just touched a goomba. If Mario didn’t have the damage boost, Mario will probably hit the goomba the very next frame and die within a frame.

If you don’t have invincibility frames, you might want to figure something out.