# How can i do a healthbar in choicescript? 

**URL:** <https://forum.choiceofgames.com/t/how-can-i-do-a-healthbar-in-choicescript/39601>\
**Category:** ChoiceScript Help\
**Created:** [June 2, 2018, 1:17pm UTC](https://forum.choiceofgames.com/t/how-can-i-do-a-healthbar-in-choicescript/39601 "2018-06-02T13:17:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elvendwarf](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@Elvendwarf](https://forum.choiceofgames.com/u/Elvendwarf)\
**Post date:** [June 2, 2018, 1:17pm UTC](https://forum.choiceofgames.com/t/how-can-i-do-a-healthbar-in-choicescript/39601/1 "2018-06-02T13:17:19Z")

</div>

you know, when that variable is 0 the game ends (sorry, i’m spanish and its hard to talk in english)

---

<div class="post-metadata">

**Author:** ![EclecticEccentric](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/eclecticeccentric/32/112816_2.png) [@EclecticEccentric](https://forum.choiceofgames.com/u/EclecticEccentric)\
**Post date:** [June 2, 2018, 1:31pm UTC](https://forum.choiceofgames.com/t/how-can-i-do-a-healthbar-in-choicescript/39601/2 "2018-06-02T13:31:03Z")

</div>

If in the stats screen, you can use the

```
*stat_chart
    percent (variable)

```

to display a bar.

For ending the game when a variable reaches zero, you can use `*gosub` commands to check if it’s zero or not, and use it to go to a scene where the game ends.

You can also use `*if` statements to check if the variable has reached zero, but the code will have to be copy-pasted to every instance where the variable has decreased.

---

<div class="post-metadata">

**Author:** ![Szaal](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/szaal/32/112202_2.png) [@Szaal](https://forum.choiceofgames.com/u/Szaal)\
**Post date:** [June 2, 2018, 2:38pm UTC](https://forum.choiceofgames.com/t/how-can-i-do-a-healthbar-in-choicescript/39601/3 "2018-06-02T14:38:03Z")

</div>

```
*stat_chart
   percent health HP

```

And when you want the game ends.

```
*if health <= 0
   game over
   tadaaa

```
