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

How would you make a part have a healthbar and if you shoot it enough it can die and respawn?

Hi guys, so I am having this problem where I want to make a part have a healthbar and if you shoot it enough it can die and respawns. Any help would be appreciated!

2 answers

lol I got easy tricks for you Go to free model and choose a npc with healthbar then make the npc's parts to invinsible except the torso then place it where you want and make sure its anchored then cttrl+2 or move tool then move it down

I don't know how to script a bit lol

You should just put the part(s) inside a model with a humanoid. The humanoid will give the whole model the "hit point" properties you are looking for. You can modify things like max health in the humanoid's properties.

As for the re-spawning when it dies, try something similar to this:

local part = script.Parent
local hum = script.Parent.Parent.Humanoid

hum.HealthChanged:Connect(function()
   if hum.Health <= 0 then
      part.Parent.Parent = game.ServerStorage
      hum.Health = hum.MaxHealth
      wait(5) -- Respawn time
      part.Parent.Parent = game.Workspace
end)

This code has not been tested, so if it does not work, you could look into this: https://developer.roblox.com/en-us/api-reference/event/Humanoid/HealthChanged

Hope this helps, let me know if you need more help!

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