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

How do i make a brick have health

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.

1 comment

0

Please help anything is great

1 answer

✓ Accepted answer

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!

2 comments

0

Thanks so much

0

Thanks it worked

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