--Char.Humanoid.BreakJointsOnDeath = false



if configuracao.EnableRagdoll == true and Char:FindFirstChild("Humanoid") then
	Char.Humanoid.Died:Connect(function()
		Ragdoll(Char)
	end)
end

local leghp = script.Parent.Parent:WaitForChild("Left Leg"):WaitForChild("HP")
local leghp2 = script.Parent.Parent:WaitForChild("Right Leg"):WaitForChild("HP")
local torsohp = script.Parent.Parent:WaitForChild("Torso"):WaitForChild("HP")
local headhp = script.Parent.Parent:WaitForChild("Head"):WaitForChild("HP")
local armhp = script.Parent.Parent:WaitForChild("Left Arm"):WaitForChild("HP")
local armhp2 = script.Parent.Parent:WaitForChild("Right Arm"):WaitForChild("HP")


local lleghp = script.Parent.Parent:WaitForChild("Left Leg"):WaitForChild("HP").MaxValue
local lleghp2 = script.Parent.Parent:WaitForChild("Right Leg"):WaitForChild("HP").MaxValue
local ltorsohp = script.Parent.Parent:WaitForChild("Torso"):WaitForChild("HP").MaxValue
local lheadhp = script.Parent.Parent:WaitForChild("Head"):WaitForChild("HP").MaxValue
local larmhp = script.Parent.Parent:WaitForChild("Left Arm"):WaitForChild("HP").MaxValue
local larmhp2 = script.Parent.Parent:WaitForChild("Right Arm"):WaitForChild("HP").MaxValue
while configuracao.EnableMedSys do
	wait()
	if Character.Humanoid.Health > 0 and Character:WaitForChild("Head"):WaitForChild("HP").Value > 0 and Character:WaitForChild("Torso"):WaitForChild("HP").Value > 0 then
		Character.Humanoid.Health = (Character:WaitForChild("Head"):WaitForChild("HP").Value + Character:WaitForChild("Torso"):WaitForChild("HP").Value + Character:WaitForChild("Left Arm"):WaitForChild("HP").Value + Character:WaitForChild("Right Arm"):WaitForChild("HP").Value + Character:WaitForChild("Left Leg"):WaitForChild("HP").Value + Character:WaitForChild("Right Leg"):WaitForChild("HP").Value)
	elseif Character:FindFirstChild("Head") ~= nil and Character:WaitForChild("Head"):WaitForChild("HP").Value <= 0 or Character:FindFirstChild("Torso") ~= nil and Character:WaitForChild("Torso"):WaitForChild("HP").Value <= 0 then
		Character.Humanoid.Health = 0
	end
	if Character.Humanoid.Health > 0 and armhp.Value > 0 and armhp2.Value > 0 or PK.Value == true then
		Steady.Value = 1
	end
	if Character.Humanoid.Health > 0 and armhp.Value <= 0 and Steady.Value > 0 and armhp2.Value > 0 and PK.Value == false then
		Steady.Value = 0.75
		Dor.Value = Dor.Value + 1
	end
	if Character.Humanoid.Health > 0 and armhp2.Value <= 0 and Steady.Value > 0 and PK.Value == false then
		Steady.Value = 0.5
	end
	if Sangrando.Value == true then
		if PastasStan.Tourniquet.Value == false then
			if script.Parent.Parent.Humanoid.Health < ultimavida -(configuracao.BleedDamage*2.25) then
				PastaVar.HeavyBleed.Value = true
			end
			--[[if leghp.Value < lleghp -(configuracao.BleedDamage) then
				wait(math.random(1,10))
				leghp.Value = (leghp.Value - 1)

			end
			if leghp2.Value < lleghp2 -(configuracao.BleedDamage) then
				wait(math.random(1,10))
				leghp2.Value = (leghp2.Value - 1)

			end
			if armhp.Value < larmhp -(configuracao.BleedDamage) then
				wait(math.random(1,10))
				armhp.Value = (armhp.Value - 1)

			end
			if armhp2.Value < larmhp2 -(configuracao.BleedDamage) then
				wait(math.random(1,10))
				armhp2.Value = (armhp2.Value - 1)

			end
			if headhp.Value < lheadhp -(configuracao.BleedDamage) then
				wait(math.random(1,10))
				headhp.Value = (headhp.Value - 1)

			end
			if torsohp.Value < ltorsohp -(configuracao.BleedDamage) then
				wait(math.random(1,10))
				torsohp.Value = (torsohp.Value - 1)

			end]]--
			if torsohp.Value > 0 then
			Sang.Value = (Sang.Value - (MLs.Value/60))
			UltimoSang = Sang.Value
				MLs.Value = MLs.Value + 1
			elseif torsohp.Value <= 0 then
				Sang.Value = (Sang.Value - (MLs.Value/60*4))
				UltimoSang = Sang.Value
				MLs.Value = MLs.Value + 4
			end
		end
	end

	if PastasStan.Tourniquet.Value == true then
		Dor.Value = Dor.Value + 0.1
	end

	if (human.Health - ultimavida < 0) then
		Sang.Value = Sang.Value + (human.Health - ultimavida)*((configuracao.BloodMult)*(configuracao.BloodMult)*(configuracao.BloodMult))
		UltimoSang = Sang.Value
	end

	if (human.Health - ultimavida < 0) then
		Dor.Value = math.ceil(Dor.Value + (human.Health - ultimavida)*(-configuracao.PainMult))
		--Energia.Value = math.ceil(Energia.Value + (human.Health - ultimavida)*(5))
	end	

	if (human.Health - ultimavida < 0) --[[and (Sangrando.Value == true)]] then
		MLs.Value = MLs.Value + ((ultimavida - human.Health)* (configuracao.BloodMult))
	end
	
	if leghp.Value > (leghp.MaxValue*.75) and leghp2.Value > (leghp.MaxValue*.75)  then
		--old one = script.Parent.Parent.Humanoid.Health < ultimavida -(configuracao.InjuredDamage)
		wait(math.random(50,100)/100)
		Ferido.Value = false
	end

	if script.Parent.Parent.Humanoid.Health < ultimavida -(configuracao.BleedDamage) then
		Sangrando.Value = true
		if script.Parent.Parent.Humanoid.Health < ultimavida -(configuracao.BleedDamage*2.25) then
			PastaVar.HeavyBleed.Value = true
		end
		if leghp.Value <= (leghp.MaxValue*.25) or leghp2.Value <= (leghp.MaxValue*.25)  then
			--old one = script.Parent.Parent.Humanoid.Health < ultimavida -(configuracao.InjuredDamage)
			Ferido.Value = true
			if  armhp.Value <= (armhp.Value/2) and armhp2.Value <= (armhp.Value/2) and torsohp.Value <= (torsohp.Value/2) and leghp.Value <= (leghp.Value/2) and leghp2.Value <= (leghp.Value/2) or headhp.Value <= (headhp.Value/2) then
				--old one = script.Parent.Parent.Humanoid.Health < ultimavida -(configuracao.KODamage)
				Caido.Value = true
			end
		end	
	end	
	
	
	if human.Health >= ultimavida and Sangrando.Value == false then
		Sang.Value = Sang.Value + 10	
		MLs.Value = MLs.Value - 10		
			
	end
		
	if Sang.Value <= 0 then
		--human.Health = 0
	end

	ultimavida = script.Parent.Parent.Humanoid.Health
	if script.Parent.Parent:FindFirstChild("Left Leg") ~= nil then
	lleghp = script.Parent.Parent:WaitForChild("Left Leg"):WaitForChild("HP").Value
	lleghp2 = script.Parent.Parent:WaitForChild("Right Leg"):WaitForChild("HP").Value
	ltorsohp = script.Parent.Parent:WaitForChild("Torso"):WaitForChild("HP").Value
	lheadhp = script.Parent.Parent:WaitForChild("Head"):WaitForChild("HP").Value
	larmhp = script.Parent.Parent:WaitForChild("Left Arm"):WaitForChild("HP").Value
	larmhp2 = script.Parent.Parent:WaitForChild("Right Arm"):WaitForChild("HP").Value
	end

	spawn(function(timer)
		if Sang.Value >= 3500 and Dor.Value < 200 and debounce == false and Caido.Value == true then
				debounce = true
				wait(60)
				Caido.Value = false
				debounce = false
			end	
		end)

end




 -- Quero um pouco de credito,plox :P --
     --  FEITO 100% POR SCORPION --
		-- Oficial Release 1.5 --