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

How can I make a health bar for a part?

So what Im trying to do is add hitpoints to this block https://imgur.com/a/7lfZH36 . I want a script which will create a health bar when I hover over it with my mouse (I have already scripted a part highlighter / selector thing) so it comes up with a green bar when I hover over it with my mouse (it gets selected) and when I click on it I want it to deplete the health bar. If you can I would also like help making it so that when the part's healthbar is empty (has no health left so 0hp) deletes itself.

I dont have any code to show you as I have absolutely nothing on this even after trying things from youtube and the internet that arent what Im after. If you need more information I will give it.

3 comments

0

Just to help anyone who is a bit confused, I want it to be similar to Treasure Hunt Simulator. A similar kind of health bar and damage things to it when you hit it with a tool and then deleting itself when it has 0 hp

0

If you are really new to scripting you should start by watching tutorials about the very basics, then move on with the specific aspects you require to make your desired script.

0

I have watched the basics, they just dont help me with what I need.

2 answers

You can use a billboard GUI with text labels and IntValues/NumberValues and have it check if the tool hit it such as if hit.Parent = "toolname". Sorry if this isn't what you need help with though.

1 comment

0

I think your going along the right lines but im completely new to scripting so I need a bit more help then that, thanks for trying though.

Gleefully, health bars are easy; you just need to add a Humanoid to the Part:

human = Instance.new("Humanoid")
human.Parent = script.Parent
human.Health = 100
human.AutoRotate = false

Expand from that point as you wish.

1 comment

0

Not sure if this will affect it but the part is a block not a human player thing

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