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.
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)
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
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.
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.
-- // 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
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.