Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Health zombie in BillboardGui on head?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
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!!

0
Thank you very much! Helped out! Yes, it helped! rikisamejima 2 — 4y
0
no problem! GravityGouse99938 75 — 4y
Ad

Answer this question