Here's the code: Note: hum doesn't mean Humanoid, but it's a folder with HP and MaxHP numbervalue.

local player = game.Players.LocalPlayer
local char = game.Workspace:FindFirstChild(player.Name)
if char then
	char2 = char
else
	char2 = game.Workspace:FindFirstChild("dragonblack6000")
end
local hum = char2:WaitForChild("Settings")
local gui = player:WaitForChild("PlayerGui")
local Bar = gui.GUI.MainGUI.Combat.Bar.Bar2:WaitForChild("Health")

local hp = hum.HP.Value
local mhp = hum.MaxHP.Value

function HealthBar()
	thp = hum.HP.Value
	tmhp = hum.MaxHP.Value
	if thp<hp then
		for i = hp/mhp,thp/tmhp,-0.05 do
			Bar.Green.Size = UDim2.new(i,0,1,0)
			wait()
		end
		Bar.Green.Size = UDim2.new(thp/tmhp,0,1,0)
	elseif thp>hp then
		for i = hp/mhp,thp/tmhp,0.05 do
			Bar.Green.Size = UDim2.new(i,0,1,0)
			wait()
		end
		Bar.Green.Size = UDim2.new(thp/tmhp,0,1,0)
	end
	hp = thp
	mhp = tmhp
end

hum.HP.Changed:connect(HealthBar)
hum.MaxHP.Changed:connect(HealthBar)

1 comment

0

Are you sure there's no problem with the hierarchy?