How would I replicate the old 2013 health humanoid GUI

image
I know a billboard GUI but there’s challenges with that approach like when you zoom out of that for some reason it gets really big, and the text looks blurry.

You would want to use a Billboard GUI, those issues you described are the result of improper properties, not an inherent problem with BillboardGui’s. If you want the UI to scale with the world, you have to set the size using the scale, not the offset (the 1st and 3rd values in the Udim2). You could then have a simply script which would copy a template GUI into the player’s character, and then have it set the adornee to the players head. The template could have the offsets and spacing set up correctly (It would just be trail and error). You could then set a TextLabel to the name, and use a simple local script to scale a frame according to the player’s health.

I’ll try to create an example, it may be a bit though to make a rough script.

I know how to make the script, the properties on the other hand are a whole different thing.

You can use Color3.fromHSV((Humanoid.Health/Humanoid.MaxHealth)*.r, .g, .b) for tweening the colors, same as for the size: UDim2.new(Humanoid.Health/Humanoid.MaxHealth,0,1,1), however designing the UI is up to you

Do you mind explaining these functions a bit?

Color3.fromHSV((Humanoid.Health/Humanoid.MaxHealth)*.3, .9, .9) is basically Humanoid.Health/100 * .3, .9,.9,
Humanoid.Health/Humanoid.MaxHealth would return a number from 0 to 1 because 100/100 = 1 and goes down respectively. I think this explains the UDim2.new too
https://gyazo.com/796d71eafa61a5deaff23d22572f826a

Here is an example I created. It’s probably not exactly what you need, but here it is to give you a start at least.
This is what it looks like:
image
image
image

This is the BillboardGui
playerTag.rbxm (4.6 KB)

I have the script set up to place it in ReplicatedStorage.
Here is the script:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RS = game:GetService("RunService")
local player = Players:GetPlayerFromCharacter(script.Parent)
local playerTag = ReplicatedStorage:WaitForChild("PlayerTag"):Clone()
local nameTag = playerTag:WaitForChild("Name")
local healthBar = playerTag:WaitForChild("Healthbar")
local humanoid = script.Parent:WaitForChild("Humanoid")

--Setting up intital stuff
humanoid.NameDisplayDistance = 0
humanoid.HealthDisplayDistance = 0
playerTag.Parent = script.Parent
playerTag.Adornee = script.Parent:WaitForChild("Head")
nameTag.Text = player.Name
healthBar.BackgroundColor3 = Color3.new(0,1,0)

local function updateHealthBar()
	local playerHealth = humanoid.Health
	local healthBarColor3 = Color3.new(1 - (playerHealth / humanoid.MaxHealth), (playerHealth / humanoid.MaxHealth), 0)
	healthBar.Size = UDim2.new(playerHealth / humanoid.MaxHealth, 0, 0.3, 0)
	healthBar.BackgroundColor3 = healthBarColor3
end

RS:BindToRenderStep("updateHealthBar", 301, updateHealthBar)

It’s a script placed in StarterCharacterScripts. If you just want the tag to be local, make it a localscript, if you want everyone to see other’s tags, make it a normal script.

The color is just a very basic interpolation of sorts between green and red, it is a very ugly color at around 50%, I’m sure there is something you can edit in the script to make that not the case, but as I said before, this is a simple example to help you create a final product.

1 Like