How would I make a heart health system?

I’m working on a bullet-hell style game and I want to make a heart-health system so that it’s more impactful if you get hit by a projectile.

I so far have made it so when your health reaches 66, 33, and 0 it shows hearts disappearing, but that’s basically a health bar and I want an actual system. The reason for this is that I want to make powerups that give you extra hearts. Is there any way I could do this?

Anything is appreciated!

just check if the player’s health has reached a certain point, then a heart GUI goes invisible. and if the health is 100 all hearts are visible

lets say that each heart = 20 hp.
to figure out how many full hearts there are, you’d do:

local fullhearts = math.floor(hp/20) --by diving the health by 20 then rounding down, you get how many 20's you can fit in the number "hp"

then for figuring how large/transparent the current heart is, you’d do this:

local currentheart = hp-(fullhearts*20) --Getting how much hp is in the current heart.
local heartrange = currentheart/20 --Gives a number on the scale between 0 and 1 for how full the heart is, you can use this for gui stuffs.

and because of how this is written, you could make the gui exponentially expand the more hp the player has.

1 Like