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

Health Gui of an object on the screen?

Asked by 2 years ago

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

Log in to vote
0
Answered by
ryanzhzh 128
2 years ago
Edited 2 years ago

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)

0
Thats the character health, im trying to make a specific objects health project in a gui on my screen VirusGodenot_br 0 — 2y
0
What sort of object do you mean?? rizdoesntlikeyou 0 — 2y
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 VirusGodenot_br 0 — 2y
0
Then set the humanoid to the enemy's humanoid! And just, use billboard guis then and then modify it. ryanzhzh 128 — 2y
Ad

Answer this question