Just as the title says, so im using a radial health bar ui that works perfectly fine until i change the max health. When the max health changes the ui dosent update it says the same.

Heres the code:

local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")

game:GetService("RunService").RenderStepped:Connect(function()
	script.Parent.Value = Humanoid.Health
	-- Progress.
	local PercentNumber = math.clamp(script.Parent.Value * 3.6,0,360)
	local F1 = script.Parent.Parent.Frame1.ImageLabel
	local F2 = script.Parent.Parent.Frame2.ImageLabel
	F1.UIGradient.Rotation = script.FlipProgress.Value == false and math.clamp(PercentNumber,180,360) or 180 - math.clamp(PercentNumber,0,180)
	F2.UIGradient.Rotation = script.FlipProgress.Value == false and math.clamp(PercentNumber,0,180) or 180 - math.clamp(PercentNumber,180,360)
	F1.ImageColor3 = script.ImageColor.Value
	F2.ImageColor3 = script.ImageColor.Value
	F1.ImageTransparency = script.ImageTrans.Value
	F2.ImageTransparency = script.ImageTrans.Value
	F1.Image = "rbxassetid://" .. script.ImageId.Value
	F2.Image = "rbxassetid://" .. script.ImageId.Value
	if script.MissingPartType.Value == "Color" then
		F1.UIGradient.Color = ColorSequence.new({ColorSequenceKeypoint.new(0,script.ColorOfPercentPart.Value),ColorSequenceKeypoint.new(0.5,script.ColorOfPercentPart.Value),ColorSequenceKeypoint.new(0.501,script.ColorOfMissingPart.Value),ColorSequenceKeypoint.new(1,script.ColorOfMissingPart.Value)})
		F2.UIGradient.Color = ColorSequence.new({ColorSequenceKeypoint.new(0,script.ColorOfPercentPart.Value),ColorSequenceKeypoint.new(0.5,script.ColorOfPercentPart.Value),ColorSequenceKeypoint.new(0.501,script.ColorOfMissingPart.Value),ColorSequenceKeypoint.new(1,script.ColorOfMissingPart.Value)})
		F1.UIGradient.Transparency = NumberSequence.new(0)
		F2.UIGradient.Transparency = NumberSequence.new(0)
	elseif script.MissingPartType.Value == "Trans" then
		F1.UIGradient.Transparency = NumberSequence.new({NumberSequenceKeypoint.new(0,script.TransOfPercentPart.Value),NumberSequenceKeypoint.new(0.5,script.TransOfPercentPart.Value),NumberSequenceKeypoint.new(0.501,script.TransOfMissingPart.Value),NumberSequenceKeypoint.new(1,script.TransOfMissingPart.Value)})
		F2.UIGradient.Transparency = NumberSequence.new({NumberSequenceKeypoint.new(0,script.TransOfPercentPart.Value),NumberSequenceKeypoint.new(0.5,script.TransOfPercentPart.Value),NumberSequenceKeypoint.new(0.501,script.TransOfMissingPart.Value),NumberSequenceKeypoint.new(1,script.TransOfMissingPart.Value)})
		F1.UIGradient.Color = ColorSequence.new(Color3.new(1,1,1))
		F2.UIGradient.Color = ColorSequence.new(Color3.new(1,1,1))
	elseif script.MissingPartType.Value == "TransAndColor" then
		F1.UIGradient.Transparency = NumberSequence.new({NumberSequenceKeypoint.new(0,script.TransOfPercentPart.Value),NumberSequenceKeypoint.new(0.5,script.TransOfPercentPart.Value),NumberSequenceKeypoint.new(0.501,script.TransOfMissingPart.Value),NumberSequenceKeypoint.new(1,script.TransOfMissingPart.Value)})
		F2.UIGradient.Transparency = NumberSequence.new({NumberSequenceKeypoint.new(0,script.TransOfPercentPart.Value),NumberSequenceKeypoint.new(0.5,script.TransOfPercentPart.Value),NumberSequenceKeypoint.new(0.501,script.TransOfMissingPart.Value),NumberSequenceKeypoint.new(1,script.TransOfMissingPart.Value)})
		F1.UIGradient.Color = ColorSequence.new({ColorSequenceKeypoint.new(0,script.ColorOfPercentPart.Value),ColorSequenceKeypoint.new(0.5,script.ColorOfPercentPart.Value),ColorSequenceKeypoint.new(0.501,script.ColorOfMissingPart.Value),ColorSequenceKeypoint.new(1,script.ColorOfMissingPart.Value)})
		F2.UIGradient.Color = ColorSequence.new({ColorSequenceKeypoint.new(0,script.ColorOfPercentPart.Value),ColorSequenceKeypoint.new(0.5,script.ColorOfPercentPart.Value),ColorSequenceKeypoint.new(0.501,script.ColorOfMissingPart.Value),ColorSequenceKeypoint.new(1,script.ColorOfMissingPart.Value)})
	else
		script.MissingPartType.Value = "TransAndColor"
	end
end)

how would i go about the ui updating when the max health changes?

5 comments

0

Humanoid.Changed:Connect(function() text = maxhealth --How you put it.

0

Using Changed in the Humanoid is a terrible idea, it'd be better to use GetPropertyChangedSignal. Humanoid:GetPropertyChangedSignal("MaxHealth"):Connect(function) where function is your function to update the UI.

0

not if you put if humanoid.maxhealth

0

The humanoid changes so much, it would be painful to keep checking if the change was from max health, and would take a lot more reasources.

0

The humanoid changes so much, it would be painful to keep checking if the change was from max health, and would take a lot more reasources.