Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Health zombie in BillboardGui on head?

How do I apply a script to a zombie so that when it changes the number of lives it is shown in the BillboardGui above its head? I made them visible, but they are always visible, and I need them to be shown when taking damage --- its my script.

local zombie = script.Parent.Parent.Parent.Zombie

while true do script.Parent.TextLabel.Text = zombie.Health wait() end



The solution is this, I took the script and rewrote it, there were a few errors, but here is the finished script:


local Zombie = script.Parent -- so you need to do it inside of zombie, or put here your path local Hum = Zombie:WaitForChild("Humanoid") -- Humanoid or Zombie, look right local Billboard = Zombie.Head:WaitForChild("BillboardGui") -- the billboard gui with health Billboard.Enabled = false -- disable it for now

Hum:GetPropertyChangedSignal("Health"):Connect(function() -- check health changed Billboard.Enabled = true -- enable gui back Billboard.TextLabel.Text = Hum.Health -- change the Billboard's text to zombie's Hum() end)

1 answer

✓ Accepted answer
local Zombie = script.Parent -- so you need to do it inside of zombie, or put here your path
local Hum = zombie:WaitForChild("Humanoid") -- zombie's humanoid. change to yours
local Billboard = Zombie.Head:WaitForChild("BillboardGui") -- the billboard gui with health
Billboard.Enabled = false -- disable it for now


Humanoid:GetPropertyChangedSignal("Health"):Connect(function() -- check health changed
	Billboard.Enabled = true -- enable gui back
	Billboard.TextLabel.Text = Humanoid.Health -- change the Billboard's text to zombie's 
	health
end)

That's basically all the code, hope it worked!!

2 comments

0

Thank you very much! Helped out! Yes, it helped!

0

no problem!

This discussion is preserved as it was. New answers, comments, and votes are closed.