Health bar of an npc gui

so im trying to make a very basic aim training game for a certain genre. i need a gui that can track a NPC’s health bar. or i at least need a way to transfer information about a NPC’s health to a variable. help would be much appreaciated

Put a text label in a bill board gui above their head.
Npc
—> Humanoid
—>BillBoard Gui → TextLabel

Local humanoid = --define npc's humanoid there
local textlabel = --define here

humanoid.Health.Changed:Connect(function()
       local size = humanoid.Health/humanoid.MaxHealth
       textlabel.Size = Udim2.new(size,0,1,0)
       
end)
4 Likes

sorry i shoudlve been more clear, i need the exact number of health left on the NPC, onto a text label, not measured by the size of a gui

you can just do:

local humanoid  = --define
humanoid.Health.Changed:Connect(function()
textlabel.Text =  humanoid.Health.."/"..humanoid.MaxHealth
end)
2 Likes

I would also add humanoid.MaxHealth.Changed if your npc is going to change it’s max health.

1 Like

If anybody is having an issue with this script and is not experienced enough to figure out why it is not working then change Health.Changed to HealthChanged

1 Like