-- regeneration

function regenHealth()
	if Humanoid.Health == 0 then -- Ded
		regening = false 
		z = Figure:GetChildren() 
		for i= 1, #z do 
			if z[i].ClassName == "Shirt" or z[i].ClassName == "Pants" or z[i].ClassName == "Body Colors" then
				z[i]:Destroy()		
			elseif z[i].ClassName == "Part" then
				part = z[i]		
				part.Transparency = 0.5
				part.BrickColor = BrickColor.new("Deep orange")
				part.Reflectance = 0.2
				lit = Instance.new("PointLight", part)
				lit.Color = Color3.new(1,187/255,28/255)
				bv = Instance.new("BodyVelocity", part)
				bv.velocity = Vector3.new(math.random(-1,1),math.random(-1,1),math.random(-1,1)) 
				part.RotVelocity =  Vector3.new(math.random(-1,1),math.random(-1,1),math.random(-1,1)) 
			elseif z[i].ClassName == "Hat" then
				part = z[i].Handle
				part.Mesh.TextureId = "" 
				part.Transparency = 0.5
				part.Reflectance = 0.2
				part.BrickColor = BrickColor.new("Deep orange")
				lit = Instance.new("PointLight", part)
				lit.Color = Color3.new(1,187/255,28/255)
				bv = Instance.new("BodyVelocity", part)
				bv.velocity = Vector3.new(math.random(-1,1),math.random(-1,1),math.random(-1,1)) 
				part.RotVelocity =  Vector3.new(math.random(-1,1),math.random(-1,1),math.random(-1,1)) 
			end
		end 
		for l = 1, 10 do
			wait(0.3)
				for i= 1, #z do 
				if z[i].ClassName == "Part" then
					z[i].Transparency = z[i].Transparency + 0.08
				elseif z[i].ClassName == "Hat" then
					z[i].Handle.Transparency = z[i].Handle.Transparency + 0.08
					 
				end
			end 
		end
		Figure:Destroy() 
	end
	if regening then return end
	regening = true
	
	while Humanoid.Health < Humanoid.MaxHealth do
		local s = wait(1)
		local health = Humanoid.Health
		if health > 0 and health < Humanoid.MaxHealth then
			local newHealthDelta = 0.01 * s * Humanoid.MaxHealth
			health = health + newHealthDelta
			Humanoid.Health = math.min(health,Humanoid.MaxHealth)
		end
		if Humanoid.Health == 0 then
			game.Debris:AddItem(Figure, 6) 
		end
		
	end
	
	if Humanoid.Health > Humanoid.MaxHealth then
		Humanoid.Health = Humanoid.MaxHealth
	end
	
	
	regening = false
end
local ourtool = nil
function Check()
 tool = nil
		z = char:GetChildren() 
		for i= 1, #z do 
		if z[i].ClassName == "Tool" then
		tool = z[i]
		end
		end 
		if tool == nil then
			if ourtool ~= nil then
			ourtool:Destroy()
			ourtool = nil
			end 
		else
			ourtool = tool:clone()
			ourtool.Parent = Figure
			Humanoid:EquipTool(ourtool)
		end
end
Check()
char.ChildAdded:connect(Check)
char.ChildRemoved:connect(Check)
Humanoid.HealthChanged:connect(regenHealth)
  
