-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------

local Vida = script.Parent.Stats.Frame.Vida
local Consciente = script.Parent.Stats.Frame.Consciente
local Dor = script.Parent.Stats.Frame.Dor
local Ferido = script.Parent.Stats.Frame.Ferido
local Sangrando = script.Parent.Stats.Frame.Sangrando

local BleedTween = TS:Create(Sangrando, TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,-1,true), {TextColor3 =  Color3.fromRGB(255, 0, 0)} )
BleedTween:Play()

RS.RenderStepped:connect(function()
	if script.Parent.Visible == true then

		if Target.Value ~= nil then
			local player = game.Players:FindFirstChild(Target.Value.Name)
			local P2_Client = player.Character:FindFirstChild("ACS_Client")

			if player and P2_Client then
				local vHuman = player.Character.Humanoid
				local vSang = player.Character.ACS_Client.Variaveis.Sangue

				local pie = (vHuman.Health / vHuman.MaxHealth)
				script.Parent.Overview.Frame.VidaBar.Bar.Size = UDim2.new(pie, 0, 1, 0)

				local Pizza = (vSang.Value / vSang.MaxValue)
				script.Parent.Overview.Frame.SangueBar.Bar.Size = UDim2.new(Pizza, 0, 1, 0)
			else
				Target.Value = nil
			end
		else
			local pie = (Human.Health / Human.MaxHealth)
			script.Parent.Overview.Frame.VidaBar.Bar.Size = UDim2.new(pie, 0, 1, 0)

			local Pizza = (Saude.Variaveis.Sangue.Value / Saude.Variaveis.Sangue.MaxValue)
			script.Parent.Overview.Frame.SangueBar.Bar.Size = UDim2.new(Pizza, 0, 1, 0)

		end


		if Target.Value == nil then
			if Human.Health <= 0 then
				Vida.Text = "Dead"
				Vida.TextColor3 = Color3.fromRGB(255,0,0)
				Consciente.Visible = false
			elseif Human.Health <= (Human.MaxHealth * .5) then
				Vida.Text = "High Risk"
				Vida.TextColor3 = Color3.fromRGB(255,0,0)
				Consciente.Visible = true
			elseif Human.Health <= (Human.MaxHealth * .75) then
				Vida.Text = "Low Risk"
				Vida.TextColor3 = Color3.fromRGB(255,255,0)
				Consciente.Visible = true
			elseif Human.Health <= (Human.MaxHealth) then
				Vida.Text = "Healthy"
				Vida.TextColor3 = Color3.fromRGB(255,255,255)
				Consciente.Visible = true
			end

			if Saude:GetAttribute("Collapsed") == true then
				Consciente.Text = "Unconscious"
			else
				Consciente.Text = "Conscious"
			end
			
			if Saude.Variaveis.Dor.Value <= 0 then
				Dor.Text = "No pain"
				Dor.TextColor3 = Color3.fromRGB(255,255,255)
				Dor.Visible = false
			elseif Saude.Variaveis.Dor.Value <= 50 then
				Dor.Text = "Minor pain"
				Dor.TextColor3 = Color3.fromRGB(255,255,255)
				Dor.Visible = true
			elseif Saude.Variaveis.Dor.Value < 100 then
				Dor.Text = "Major pain"
				Dor.TextColor3 = Color3.fromRGB(255,255,0)
				Dor.Visible = true
			elseif Saude.Variaveis.Dor.Value >= 100 then
				Dor.Text = "Extreme pain"
				Dor.TextColor3 = Color3.fromRGB(255,0,0)
				Dor.Visible = true
			end


			if Saude:GetAttribute("Injured") == true then
				Ferido.Visible = true
			else
				Ferido.Visible = false
			end

			if Saude:GetAttribute("Bleeding") == true or Saude:GetAttribute("Tourniquet")then
				if Saude:GetAttribute("Tourniquet") then
					Sangrando.Text = 'Tourniquet'
				else
					Sangrando.Text = 'Bleeding'
				end
				Sangrando.Visible = true
			else
				Sangrando.Visible = false
			end

		else
			local player2 = game.Players:FindFirstChild(Target.Value.Name)
			local PlHuman = player2.Character.Humanoid
			local PlSaude = player2.Character.ACS_Client
			if PlHuman.Health > 0 then
				if PlHuman.Health <= 0 then
					Vida.Text = "Dead"
					Vida.TextColor3 = Color3.fromRGB(255,0,0)
					Consciente.Visible = false
				elseif PlHuman.Health <= (PlHuman.MaxHealth * .5) then
					Vida.Text = "High Risk"
					Vida.TextColor3 = Color3.fromRGB(255,0,0)
					Consciente.Visible = true
				elseif PlHuman.Health <= (PlHuman.MaxHealth * .75) then
					Vida.Text = "Low Risk"
					Vida.TextColor3 = Color3.fromRGB(255,255,0)
					Consciente.Visible = true
				elseif PlHuman.Health <= (PlHuman.MaxHealth) then
					Vida.Text = "Healthy"
					Vida.TextColor3 = Color3.fromRGB(255,255,255)
					Consciente.Visible = true
				end

				if PlSaude:GetAttribute("Collapsed") == true then
					Consciente.Text = "Unconscious"
				else
					Consciente.Text = "Conscious"
				end

				if PlSaude.Variaveis.Dor.Value <= 0 then
					Dor.Text = "No pain"
					Dor.TextColor3 = Color3.fromRGB(255,255,255)
					Dor.Visible = false
				elseif PlSaude.Variaveis.Dor.Value <= 50 then
					Dor.Text = "Minor pain"
					Dor.TextColor3 = Color3.fromRGB(255,255,255)
					Dor.Visible = true
				elseif PlSaude.Variaveis.Dor.Value < 100 then
					Dor.Text = "Major pain"
					Dor.TextColor3 = Color3.fromRGB(255,255,0)
					Dor.Visible = true
				elseif PlSaude.Variaveis.Dor.Value >= 100 then
					Dor.Text = "Extreme pain"
					Dor.TextColor3 = Color3.fromRGB(255,0,0)
					Dor.Visible = true
				end

				if PlSaude:GetAttribute("Injured") == true then
					Ferido.Visible = true
				else
					Ferido.Visible = false
				end

				if PlSaude:GetAttribute("Bleeding") == true or PlSaude:GetAttribute("Tourniquet") then
					if PlSaude:GetAttribute("Tourniquet")then
						Sangrando.Text = 'Tourniquet'
					else
						Sangrando.Text = 'Bleeding'
					end
					Sangrando.Visible = true
				else
					Sangrando.Visible = false
				end
			end
		end
	end

end)