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

How do i make a brick have health

Asked by 10 years ago

How do i make a brick have health and when the health is about 50% a smoke inside the brick is enabled?? I know how to enable the smoke but i don't know how to make it so it enabls it when the health is at a certain number. This is for a engine that can smoke if it takes damage.

Please help thanks.

0
Please help anything is great SirKitten2000 0 — 10y

1 answer

Log in to vote
7
Answered by
AxeOfMen 434 Moderation Voter
10 years ago

To make a brick with a health bar:

  • Create a model in workspace
  • Add a part to the model and name it "Head"
  • Add a Humanoid to the model
  • Add a smoke object to the part named Head. Disable the smoke.
  • Add a script to the model

Inside the script, add this code:

local humanoid = script.Parent.Humanoid
local smoke = script.Parent.Head.Smoke
humanoid.HealthChanged:connect(function(health)
    smoke.Enabled = health <= 50
end)

[Edit] I modified the logic in the script a little bit so that if the health of the humanoid increases above 50 (via a health regen script or something) then it will stop smoking.

Have fun!

0
Thanks so much SirKitten2000 0 — 10y
0
Thanks it worked SirKitten2000 0 — 10y
Ad

Answer this question