Pages: 1
Topic closed
Okay, so both my brother and I are having this problem on our Scratch game projects. When the hero sprite attacks an enemy, a variable called Health (visible on the screen) depletes with each hit. The problem: when Health reaches 0, it continues to go into negative numbers...
I've tried:
If [ Health = 0 ]
((hide/change costume/etc.))
If [ Health < 0 ]
((hide/change costume/etc.))
No matter what I do with the Health variable, I can't get it to stop. I have about 3 Scratch projects with a Health, hunger or thirst bar with this same problem. So, how do you fix it?
Offline
Checking if health is less than 0 (or more preferably, 1) should work. Does your script look something like this? (Possibly with other things in there too, but I don't know what the rest of your scripts look like.
When green flag clicked forever if <health < 1> hide
Offline
It looks like changing "if" to "forever if" made it work! Thanks.
Offline
DewleafWolf wrote:
It looks like changing "if" to "forever if" made it work! Thanks.
That's because "Forever If" constantly checks whether something is true or not, while a plain "if" block checks it only in the moment you run it.
Offline
Ah, okay, that makes sense! I'm still learning most of the blocks' functions, so that helps.
Offline
Topic closed
Pages: 1