Boss health bar

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.

You have to make a value with only 3 health points then.

Make a.Changed to the value
Take the bars away for the health
Name the bars 1,2,3 for it to be easy.

Value.Changed:Connect(function(new)
for i,v in pairs(gui:GetChildren()) do
if i >= new then v.Visible = false
end end end)

so make a value for the health?

Yes. You need to make a custom value if they only have 3 hit points.

I made a value for the health but it doesn’t update when it loses health.

local BossHealth = game.workspace.Boss.Humanoid.Health
local HealthValue = script.parent

while true do
HealthValue.Value = BossHealth
end