Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to put a health bar up in scratch
- Shadow844
-
New Scratcher
2 posts
How to put a health bar up in scratch
I need help with putting a health bar up in scratch and i have already tried many things PLZ HELP ME!
- elias_the_dank
-
New Scratcher
9 posts
How to put a health bar up in scratch
There are multiple ways to create a “health bar” in Scratch. You can create a variable for your character's health and just change it whenever it gets “hit” like this:
Later on you may learn about using Pen blocks to create a more advanced health bar, but right now this is probably the simplest way to do it. I hope this helps, good luck on your project!
when green flag clicked
set [health v] to [100]
forever
if <touching [something bad v] ?> then // Change "something bad" to whatever sprite that will do damage to your character
change [health v] by (-10)
end
wait until <not <touching [something bad v] ?>> // This part just makes sure that your character won't die the first time it gets "hit"
end
Later on you may learn about using Pen blocks to create a more advanced health bar, but right now this is probably the simplest way to do it. I hope this helps, good luck on your project!

- -alexjai1
-
Scratcher
19 posts
How to put a health bar up in scratch
Use a variable for the number of health you have, (e.g.
health = 0). Name each costume with the number of health that costume represents e.g. name the 9/10 one “9”. Have something like this to continuously switch to the correct costume.
This is quite a wordy explanation, but I hope it helps.
set [health v] to [10]and make a health bar sprite, and make ten different costumes, for when you lose 1 health, it switches to a costume with a health bar showing 9/10 full. Then you keep losing health, every one health lost the costume switches. 0/10 health bar
health = 0). Name each costume with the number of health that costume represents e.g. name the 9/10 one “9”. Have something like this to continuously switch to the correct costume.foreverBy the way, put the health variable oval in the costume slot (where “(health)” is)
switch costume to [(health) v]
end
This is quite a wordy explanation, but I hope it helps.
Last edited by -alexjai1 (Dec. 19, 2017 20:43:29)
- hirsh001
-
Scratcher
100+ posts
How to put a health bar up in scratch
You can use pen to draw the health bar(Pen size equals diameter). That way, you can have is display an any(not really cause pixles) number of health. If you need help, I can provide the code, but you would need to share the project.
Last edited by hirsh001 (Dec. 24, 2017 23:54:25)
- sabas_ll
-
Scratcher
1 post
How to put a health bar up in scratch
how do i make a sprite make a different sprite lose health
- hirsh001
-
Scratcher
100+ posts
How to put a health bar up in scratch
how do i make a sprite make a different sprite lose healthjust create different health bars
- KalicatKatico
-
Scratcher
14 posts
How to put a health bar up in scratch
So my basic health bar is I make a “health bar” sprite with 4 costumes: “full”, “75%”, “50%”, and “25%”. I also make a “Health” variable. The bar sprite is linked to the variable so it changes depending on the variable's value. The code goes something like this:
when green flag clicked
if (Health = 100) then
switch costume to [costume1 v]
end
if (Health <[100] and Health > [75]) then
switch costume to [costume2 v]
end
if (Health < [75] and Health > [50]) then
switch costume to [costume3 v]
end
if (Health < [50] and Health > [25]) then
switch costume to [costume4 v]
end
if (Health < [25] and Health > [0]) then
switch costume to [costume5 v]
end
Last edited by KalicatKatico (Dec. 30, 2018 00:57:21)
- BereketY
-
Scratcher
500+ posts
How to put a health bar up in scratch
I would recommend using a sprite rather than a pen render if you are dealing with layers.
- TerraisLife
-
New Scratcher
1 post
How to put a health bar up in scratch
_
Last edited by TerraisLife (April 8, 2019 20:15:53)
- ipaddude
-
Scratcher
100+ posts
How to put a health bar up in scratch
There are multiple ways to create a “health bar” in Scratch. You can create a variable for your character's health and just change it whenever it gets “hit” like this:sorry, did you meanwhen green flag clicked
set [health v] to [100]
forever
if <touching [something bad v] ?> then // Change "something bad" to whatever sprite that will do damage to your character
change [health v] by (-10)
end
wait until <not <touching [something bad v] ?>> // This part just makes sure that your character won't die the first time it gets "hit"
end
Later on you may learn about using Pen blocks to create a more advanced health bar, but right now this is probably the simplest way to do it. I hope this helps, good luck on your project!
when green flag clicked
set [health v] to [100]
forever
if <touching [something bad v] ?> then // Change "something bad" to whatever sprite that will do damage to your character
change [health v] by (-10)
wait until <not <touching [something bad v] ?>> // This part just makes sure that your character won't die the first time it gets "hit"
end
end
Last edited by ipaddude (April 8, 2019 20:28:27)
- Kraken_Games
-
Scratcher
100+ posts
How to put a health bar up in scratch
_Don't spam or necropost - you are doing both.
There are multiple ways to create a “health bar” in Scratch. You can create a variable for your character's health and just change it whenever it gets “hit” like this:sorry, did you meanwhen green flag clicked
set [health v] to [100]
forever
if <touching [something bad v] ?> then // Change "something bad" to whatever sprite that will do damage to your character
change [health v] by (-10)
end
wait until <not <touching [something bad v] ?>> // This part just makes sure that your character won't die the first time it gets "hit"
end
Later on you may learn about using Pen blocks to create a more advanced health bar, but right now this is probably the simplest way to do it. I hope this helps, good luck on your project!when green flag clicked
set [health v] to [100]
forever
if <touching [something bad v] ?> then // Change "something bad" to whatever sprite that will do damage to your character
change [health v] by (-10)
wait until <not <touching [something bad v] ?>> // This part just makes sure that your character won't die the first time it gets "hit"
end
end
Please don't necropost
- IPlayGames_101
-
New Scratcher
1 post
How to put a health bar up in scratch
idc if this is necro posting but this helps alot
- codeman1044
-
Scratcher
1000+ posts
How to put a health bar up in scratch
idc if this is necro posting but this helps alotGlad it helps but yes, you're necroposting, so please refrain from doing it.
Last edited by codeman1044 (Oct. 16, 2019 00:23:31)
- CrazyCoolV
-
Scratcher
1 post
How to put a health bar up in scratch
how would you make your sprite ‘die’ after the health bar is empty?
- Wainggan
-
Scratcher
500+ posts
How to put a health bar up in scratch
how would you make your sprite ‘die’ after the health bar is empty?Welcome to the forums! Please create your own topic, and don't necropost~
- PersRufaro
-
Scratcher
100+ posts
How to put a health bar up in scratch
efdfsefsePlease don't necropost. It's when you post on an old topic. Thank you

- FoofJr
-
Scratcher
100+ posts
How to put a health bar up in scratch
when green flag clicked
set [health v] to [10]
forever
if <touching [something bad v]> then
change [health v] by [-1]
end
end
- Discussion Forums
- » Help with Scripts
-
» How to put a health bar up in scratch
