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?
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?
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
Thats the character health, im trying to make a specific objects health project in a gui on my screen
What sort of object do you mean??
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
Then set the humanoid to the enemy's humanoid! And just, use billboard guis then and then modify it.