Radial Health Bar Help

Hello! :wave:

I’m trying to make a radial health bar for the player using UIGradient and with the help of this forum post.

So I designed a radial health bar around the player’s feet to indicate the player’s health.

I used :GetPropertyChangedSignal() to figure out if the player’s health is being changed, and then I hooked it up with this code below:

Code
--Services
local Players = game:GetService('Players')

--Player
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild('Humanoid')

--Variables
local Main = script.Parent.Main
local Health, MaxHealth = Humanoid.Health, Humanoid.MaxHealth
--Functions
local function CurvedBarResize(bar, alpha)
	print(alpha)
	bar.UIGradient.Rotation = -90 * (1 - alpha)
	if alpha - 0.001 <= 0 then
		bar.UIGradient.Transparency = NumberSequence.new(1, 1)
	elseif alpha == 1 then
		bar.UIGradient.Transparency = NumberSequence.new(0, 0)
	else
		local subtract = alpha - 1
		bar.UIGradient.Transparency = NumberSequence.new({
			NumberSequenceKeypoint.new(0, 0),
			NumberSequenceKeypoint.new(subtract, 0),
			NumberSequenceKeypoint.new(alpha, 1),
			NumberSequenceKeypoint.new(1, 1)
		})
	end
end

local function UpdateHud()
	
	local circleAlpha = MaxHealth / 3
	local bottomRightAlpha = MaxHealth * (2/3) --66
	local topRightAlpha = MaxHealth * (2/4.5) -- 44
	local topLeftAlpha =	MaxHealth * (1/3) --33
	local bottomLeftAlpha = MaxHealth * (1/8) --12.5
	
	
	if Health <= MaxHealth then
		if Health >= bottomRightAlpha then
			Main.BottomRight.Green.UIGradient.Transparency = NumberSequence.new(0, 0)
			Main.TopRight.Green.UIGradient.Transparency = NumberSequence.new(0, 0)
			Main.BottomLeft.Green.UIGradient.Transparency = NumberSequence.new(0, 0)
			Main.TopLeft.Green.UIGradient.Transparency = NumberSequence.new(0, 0)
			
			local alpha = (Health - bottomRightAlpha) / circleAlpha
			CurvedBarResize(Main.BottomRight.Green, alpha)
			
		elseif Health >= topRightAlpha then
			Main.BottomRight.Green.UIGradient.Transparency = NumberSequence.new(1, 1)
			Main.TopRight.Green.UIGradient.Transparency = NumberSequence.new(0, 0)
			Main.BottomLeft.Green.UIGradient.Transparency = NumberSequence.new(0, 0)
			Main.TopLeft.Green.UIGradient.Transparency = NumberSequence.new(0, 0)
			
			local alpha = (Health - topRightAlpha) / circleAlpha
			CurvedBarResize(Main.TopRight.Green, alpha)
			
		elseif Health >= topLeftAlpha then
			Main.BottomRight.Green.UIGradient.Transparency = NumberSequence.new(1, 1)
			Main.TopRight.Green.UIGradient.Transparency = NumberSequence.new(1, 1)
			Main.BottomLeft.Green.UIGradient.Transparency = NumberSequence.new(0, 0)
			Main.TopLeft.Green.UIGradient.Transparency = NumberSequence.new(0, 0)
			
			local alpha = (Health - topLeftAlpha) / circleAlpha
			CurvedBarResize(Main.TopLeft.Green, alpha)
			
		elseif Health >= bottomLeftAlpha then
			Main.BottomRight.Green.UIGradient.Transparency = NumberSequence.new(1, 1)
			Main.TopRight.Green.UIGradient.Transparency = NumberSequence.new(1, 1)
			Main.BottomLeft.GreenUIGradient.Transparency = NumberSequence.new(0,0)
			Main.TopLeft.Green.UIGradient.Transparency = NumberSequence.new(1,1)
			
			local alpha = (Health - bottomLeftAlpha) / circleAlpha
			CurvedBarResize(Main.BottomLeft.Green, alpha)
		end
	end
end

Humanoid:GetPropertyChangedSignal('Health'):Connect(UpdateHud)

However, there are some problems with this.

Whenever I try to change the player’s health this happens:

If I set the player’s health to 50, for example, the health bar will still display the same thing as the image above.

Is there a way I could make it work properly? Thanks in advance.

4 Likes

Have you figured out how to do this and if so can u show me or tell me how because im stuck trying to make something like this

hey man, you shouldn’t really just straight up ask for the code instead maybe you can show us what you tried so we can help you.

Do you get any console errors?

Well I’ve tried using the roatation property to do this and have not found success

Can you explain that or show what you have? Im not following clearly on the method you use

No errors just don’t know how to code it and seeking for help

Wait, your not even the topic OP. Your code is probably different than the topic OP. You should open your own thread instead of necro-bumping this one.