For the bottom bar, which is what I’m trying to achieve, I’m not really sure how I would go about scripting it. Basically, it will show how much health the boss has before it will lose a life, then once it reaches that number it will be full size until more damage is taken. (unless the boss has 0 lives, in which case the GUI dissapears)
All I’ve got so far is this:
local Lives, MaxLives = Boss:GetAttribute(“Lives”), Boss:GetAttribute(“MaxLives”)
If anyone is able to help with this, I would appreciate it very much!
The bottom bar shows how much health the boss has before it loses that life. The amount of health for each life is the boss’s MaxHealth divided by how many lives there are.
Yes, I’m going to make it so when the boss is block broken you can do a takedown move and it will lose one of its lives. (depending on how many lives the boss has is how much damage the takedown will do)
Try something like this just to get an idea you can just use this as like boilerplate, (im guessing you know enough to do the UI related stuff)
local Boss = {}
-- Constants
local NUM_BARS = 4
local MAX_HEALTH = 100
Boss.healthBars = {}
function Boss:Init()
for i = 1, NUM_BARS do
self.healthBars[i] = MAX_HEALTH
end
end
function Boss:Damage(amount)
for i = 1, NUM_BARS do
if self.healthBars[i] > 0 then
self.healthBars[i] = math.max(self.healthBars[i] - amount, 0)
break -- Exit the loop after damaging one health bar
end
end
end
function Boss:IsDefeated()
for i = 1, NUM_BARS do
if self.healthBars[i] > 0 then
return false
end
end
return true
end
Boss:Init()
Boss:Damage(25)
print(Boss.healthBars) -- Output: { 75, 100, 100, 100 }
print(Boss:IsDefeated()) -- Output: false