Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Use if statements with variables? (FIXED)
- PigMayor
-
Scratcher
2 posts
Use if statements with variables? (FIXED)
I'm trying to make my game advance to another area after a boss reaches 0 Health (with Health being a variable), but I don't know if/how I can since I can't put my variable into an if or if/else statement. Any solutions? D:
Last edited by PigMayor (June 22, 2016 18:40:56)
- Greatguy123
-
Scratcher
500+ posts
Use if statements with variables? (FIXED)
You have the right idea! However, instead of putting the variable directly into the if statement, you need to use an equals block from the operators section, like this:
if <(Health) = [0]> then
end
- Sheep_maker
-
Scratcher
1000+ posts
Use if statements with variables? (FIXED)
Alternatively you could just wait until the boss's health gets below 1
wait until <(Health) < [1]>
...
- PigMayor
-
Scratcher
2 posts
Use if statements with variables? (FIXED)
Alternatively you could just wait until the boss's health gets below 1wait until <(Health) < [1]>
...
You have the right idea! However, instead of putting the variable directly into the if statement, you need to use an equals block from the operators section, like this:Thanks for the help! Now I can continue with my project!if <(Health) = [0]> then
end

- zanethecatking
-
Scratcher
2 posts
Use if statements with variables? (FIXED)
how do you make it if health is 50 or more
- deck26
-
Scratcher
1000+ posts
Use if statements with variables? (FIXED)
how do you make it if health is 50 or morePlease create your own new topic rather than necroposting next time.
if <not <(health) < [50]>> thenis one way. If you know health is a whole number you could also just check health > 49
end
- Sliceofmycat
-
Scratcher
1 post
Use if statements with variables? (FIXED)
how do you put an operater in the than part instead of the if part?
- deck26
-
Scratcher
1000+ posts
Use if statements with variables? (FIXED)
how do you put an operater in the than part instead of the if part?Please start your own new topic if you have a question. I've no idea what you mean by that though. Is the ‘than’ supposed to be ‘then’? Even if that's the case I don't know what you mean.
Perhaps better to explain what you're trying to achieve.
- cs2688203
-
New Scratcher
1 post
Use if statements with variables? (FIXED)
I have a similar question. I wanna make a sprite hide when my variable reaches a certain number. How do i do that.
- imfh
-
Scratcher
1000+ posts
Use if statements with variables? (FIXED)
I have a similar question. I wanna make a sprite hide when my variable reaches a certain number. How do i do that.Welcome to the Scratch Forums! This topic is nearly 3 years old as it was made in 2016. Posting on old topics like this is called “necroposting” which is usually not allowed. In the Help With Scripts forum, it is preferred that you create your own topic to keep things organized, even if the post isn't really old.
Here's how you could do what you want, however it might not be the best way depending on your project:
when green flag clicked // Put this in the sprite you want to hide
wait until <(variable) = [10]> // Wait until the variable is the right number
hide // Hide the sprite
If you need more help, please make your own topic. It might help to share your project and link so we can know exactly what the problem is and how to fix it.
- Discussion Forums
- » Help with Scripts
-
» Use if statements with variables? (FIXED)