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

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

Asked by
hdababo -5
3 years ago

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!

Closed as Not Constructive by BestCreativeBoy, OhManXDXD, and imKirda

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 3 years ago

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

Ad
Log in to vote
0
Answered by 3 years ago

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!