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

How to make a health gui with numbers?

So when you have max health it says 3, when you got damaged it says 2, when your almost dead it says 1, and of course when you died it says 0, here is what I have but its without numbers: local char = script.Parent.Parent.Parent.Character hum = char.Humanoid hum.Changed:connect(function() script.Parent.Frame.Health.Frame.Size = UDim2.new(hum.Health/hum.MaxHealth, 0, 1, 0) if hum.Health <= hum.MaxHealth*0.15 then script.Parent.Frame.Health.Frame.BackgroundColor3 = Color3.new(150, 0, 0) else script.Parent.Frame.Health.Frame.BackgroundColor3 = Color3.new(0, 85, 0) end end)

1 comment

0

please use code blocks.

1 answer

I can't really read the text because it isn't in a code block therefore I'll just make the script; please change any things that are essential.

1: Make a 'ScreenGui' then rename it to HealthBarGUI 2: Make a 'Frame' inside the HealthBarGUI and rename it to BackgroundFrame 3: Make the BackgroundFrame Size {0, 460},{0, 50} and Position {0.32, 0},{0.815, 0} 4: You can make the rest of it look however you want it to 5: Make a 'TextLabel' inside the BackgroundFrame 6: Rename to 'Indicator' 7: Change Size to {0, 250},{0, 30} and Position to {0, 125},{0, 8} and make the Text '3' and BackgroundTransparency to 0 8: Insert a 'LocalScript' inside the HealthBarGUI 9: Go to properties of StarterGui and make sure RestPlayerGuiOnSpawn is ticked

Copy the following code:

local player = game.Players.LocalPlayer
local Humanoid = player.Character:WaitForChild("Humanoid")
local indicator = script.Parent.BackgroundFrame.Indicator
local frame = script.Parent.BackgroundFrame

frame.BackgroundColor3 = Color3.new(0, 255, 0)

Humanoid.HealthChanged:connect(function()
	if Humanoid.Health <= 99 then
		indicator.Text = '2'
		frame.BackgroundColor3 = Color3.new(215, 245, 0)
	else if Humanoid.Health <= 25 then
		frame.BackgroundColor3 = Color3.new(255, 215, 0)
		indicator.Text = '1'
	else if Humanoid.Health <= 0 then
		frame.BackgroundColor3 = Color3.new(255, 0, 0)
		indicator.Text = '0'
		wait(6)
		indicator.Text = '3'
		frame.BackgroundColor3 = Color3.new(0, 255, 0)
		
	end
	end
	end
end)

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