Boss health bar

Right now I’m trying to make a health bar for a boss npc. Kind of like the one below.

image

How would I do this?

1 Like

Could you give us more information about what you want to achieve? I’m kinda confused when you are saying that you want to make a boss health bar, i know you showed us an image, but it’s still confusing.

if it contains a humanoid then get it’s health and just display it in a TextLabel or something.

Well heres a script, you might understand

local BossHumanoid = game.workspace.Boss.Humanoid

if BossHumanoid.Health = 50 then
print(“change gui”)
end

what are you trying to do?
printing “change gui” will not change the gui.

This can be made better but,

local humanoid = workspace:WaitForChild("Boss").Humanoid
      while true do
      Textlabel.Text = tostring(humanoid.Health)
 end

this is basically what you would have to do , there are numerous ways in which you can achieve what you want.

1 Like

I know printing “Change gui” won’t change the gui. I’m just typing it testing to see if anything will happen when the boss health is at 50 or something. But I might have an Idea of what to do for this.

I still don’t have enough information, could you explain us more? You can take your time :slight_smile:

If you want to display numerical health the following script will do it below. I did not test this script in studio.

Server Script:

local remoteEvent = game:GetService("ReplicatedStorage").remoteEvent
local boss = game.Workspace.Boss

local function updateBossBar()
      remoteEvent:FireAllClients(tostring(boss.Humanoid.Health))
end

boss.Humanoid.GetPropertyChangedSignal("Health"):Connect(updateBossBar)

Client Script:

local bossOverlay = game:GetService("Players").LocalPlayer.PlayerGui:WaitForChild("Boss GUI")
local remoteEvent = game:GetService("Replicated Storage").remoteEvent

local function updateHealth(health)
     bossOverlay.TextLabel.Text = health
end

remoteEvent.OnClientEvent:Connect(updateHealth)
1 Like

https://www.roblox.com/library/4941065626/Health-Bar (Made by me inspired by this)

1 Like

I tested this and it doesn’t update the gui when the humanoid takes damage.

Sorry for not giving alot of detail.
If you played spongebob BFBB, you might remember the king jelly fish boss. I’m trying to make something like that. When the boss takes damage, the health goes from this
image
to this
image

Did you change the humanoid inside the README?

Essentially the way the game is doing it is saying that the boss has three lives which can be taken at event periods.

The way you do this is simply through remote events and timing. When a client calls to attack the boss, if the attack can be done in the period then lower the health by 1 bar aka make the green bar invisible. Keep doing this until you have no bars left e.g. is dead.

I would go up to @xZylter 's code for this as its quite good, the only changes you’d be adding is setting rules for health. The rest of this is then just UIs and changing properties.

Here’s an explanation on how to use it Custom Health Bars

There is a HealthChanged property of humanoids.
When its health is changed, get its new health, and depending on how much health make certain guis visible.

The Humanoid.HealthChanged even fires only when the health decreases. What if the boss heals?

Considering how they want it I doubt it will go up.

Just use this script:

-- // VARIABLES
local humanoid = workspace.Model.Humanoid -- change this

-- // FUNCTIONS
humanoid:GetPropertyChangedSignal("Health"):Connect(function()
	-- Health Was Changed,
end)

If you want to use actual health bar use this formula:

local newSize = (newHealth/maxHealth) * totalFrameSize

Hope this solves everything.

This isn’t what he was wanting.
He wants 3 bars.

I probably should’ve said what the boss is & how you defeat it in the first place.
Its basically a giant npc who tries to attack you from where its standing with its weapon e.g. Sword.
There’s a catapult that launches an item towards the Boss, when it hits him the boss takes damage and loses one bar.