# Invincibility

**URL:** <https://forum.makecode.com/t/invincibility/5479>\
**Category:** Help\
**Created:** [January 11, 2021, 7:31pm UTC](https://forum.makecode.com/t/invincibility/5479 "2021-01-11T19:31:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_nico](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/_nico/32/2760_2.png) [@\_nico](https://forum.makecode.com/u/_nico)\
**Post date:** [January 11, 2021, 7:31pm UTC](https://forum.makecode.com/t/invincibility/5479/1 "2021-01-11T19:31:34Z")

</div>

How do you make invincibility and knockback after getting hit? I’ve tried doing it with my own knowledge, but I haven’t gotten anything.

---

<div class="post-metadata">

**Author:** ![shakao](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/shakao/32/113_2.png) [@shakao](https://forum.makecode.com/u/shakao)\
**Post date:** [January 11, 2021, 7:41pm UTC](https://forum.makecode.com/t/invincibility/5479/2 "2021-01-11T19:41:14Z")

</div>

One way to do invincibility is using lifespans and the sprite “on destroyed” event! The basic idea is, when the sprite is hit, you change the kind and set a lifespan (invincibility duration). When that lifespan ends, you re-create the sprite with the original properties.

Here is an example: [https://makecode.com/\_gmy7EM7KAJF0](https://makecode.com/_gmy7EM7KAJF0)

---

<div class="post-metadata">

**Author:** ![ClarkEagling](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/clarkeagling/32/4044_2.png) [@ClarkEagling](https://forum.makecode.com/u/ClarkEagling)\
**Post date:** [June 3, 2021, 3:27pm UTC](https://forum.makecode.com/t/invincibility/5479/3 "2021-06-03T15:27:14Z")

</div>

Thank you thank you! Was trying to get complicated with a function and a boolean and a pause etc etc. this is way cleaner.
