function UpdateGUI(h)local i=(game.Players:GetPlayerFromCharacter(humanoid.Parent)).PlayerGui local a=i.HealthGUI.Tray a.HealthBar.Size=UDim2.new(.2,0,.8*(h/humanoid.MaxHealth),0)a.HealthBar.Position=UDim2.new(.4,0,.8*(1-h/humanoid.MaxHealth),0)if script.Parent.Humanoid.Health<=30 then a.HealthBar.BackgroundColor3=Color3.new(1.0,.0,.0)print("\114\101\100")a.Color.Value="\082\101\100"elseif script.Parent.Humanoid.Health<=70 then a.HealthBar.BackgroundColor3=Color3.new(1.0,1.0,.0)print("\121\101\108\108\111\119")a.Color.Value="\089\101\108\108\111\119"elseif script.Parent.Humanoid.Health>70 then a.HealthBar.BackgroundColor3=Color3.new(.0,1.0,.0)print("\103\114\101\101\110")a.Color.Value="\071\114\101\101\110"end if script.Parent.Humanoid.Health==0 then print("\100\101\097\100")a.Color.Value="\068\101\097\100"end end function HealthChanged(h)UpdateGUI(h)end


function UpdateGUI(health)
	local pgui = game.Players:GetPlayerFromCharacter(humanoid.Parent).PlayerGui
	local tray = pgui.HealthGUI.Tray
	
	tray.HealthBar.Size = UDim2.new(0.2, 0, 0.8 * (health / humanoid.MaxHealth), 0) 
	tray.HealthBar.Position = UDim2.new(0.4, 0, 0.8 * (1-  (health / humanoid.MaxHealth)) , 0) 
	if script.Parent.Humanoid.Health <= 30 then
		tray.HealthBar.BackgroundColor3 = Color3.new(255/255, 0/255, 0/255)
		print("red")
		tray.Color.Value = "Red"
	elseif script.Parent.Humanoid.Health <= 70 then
		tray.HealthBar.BackgroundColor3 = Color3.new(255/255, 255/255, 0/255)
		print("yellow")
		tray.Color.Value = "Yellow"
	elseif script.Parent.Humanoid.Health > 70 then
		tray.HealthBar.BackgroundColor3 = Color3.new(0/255, 255/255, 0/255)
		print("green")
		tray.Color.Value = "Green"
	end
	if script.Parent.Humanoid.Health == 0 then
		print("dead")
		tray.Color.Value = "Dead"
	end
end


function HealthChanged(health)
	UpdateGUI(health)
end

