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

Health Gui of an object on the screen?

Ive been trying to make a health gui for an object, ive made it so its ontop of said object. But i want it to be a gui on the screen.

Does anyone have any ideas?

1 answer

Please try it first. We are not a place to ask for scripts!

Short answer:

First you'll have to get the players Humanoid.Health.

-- Local Script Example 1 --

local player = game.Players.LocalPlayer
local char = player.Character
local humanoid = char.Humanoid
local hp = humanoid.Health

From there if you are good, you should be able to do it. hint: health / maxHealth

Long answer:

local player = game.Players.LocalPlayer
local char = player.Character
local humanoid = char.Humanoid
local hp = humanoid.Health
local maxHealth = humanoid.MaxHealth
local bar -- The path to the bar, we'll never make the gui, make it yourself!

humanoid.HealthChanged:Connect(function(health)
	bar.Size = UDim2.new(health / maxHealth, 0, bar.Size.Y.Scale, bar.Size.Y.Offset)
end)

4 comments

0

Thats the character health, im trying to make a specific objects health project in a gui on my screen

0

What sort of object do you mean??

0

So im making a tower defense game, and i wanted the base that the enemies damage to have a set gui on the players screen, so they donty have to look around for a health bar

0

Then set the humanoid to the enemy's humanoid! And just, use billboard guis then and then modify it.

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