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

local TreatDebounce = true
local SavedTarget 	= nil

script.Parent.Treat.Frame.BandFrame.Bandage.MouseButton1Down:Connect(function()
	if TreatDebounce and Bandage.Value > 0 and Human.Health > 0 and not Char.ACS_Client:GetAttribute("Collapsed") then
		TreatDebounce = false
		if Target.Value == nil then
			if Char.ACS_Client:GetAttribute("Bleeding") then
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(5,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(5)
				Functions.MedHandler:FireServer(nil,1)
			end
		else
			if Target.Value.Character.ACS_Client:GetAttribute("Bleeding") then
				SavedTarget = Target.Value
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(5,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(5)
				Functions.MedHandler:FireServer(SavedTarget,1)
			end
		end
		TreatDebounce = true
	end
end)

script.Parent.Treat.Frame.BandFrame.Splint.MouseButton1Down:Connect(function()
	if TreatDebounce and Splint.Value > 0 and Human.Health > 0 and not Char.ACS_Client:GetAttribute("Collapsed") then
		TreatDebounce = false
		if Target.Value == nil then
			if Char.ACS_Client:GetAttribute("Injured") then
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(5,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(5)
				Functions.MedHandler:FireServer(nil,2)
			end
		else
			if Target.Value.Character.ACS_Client:GetAttribute("Injured") then
				SavedTarget = Target.Value
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(5,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(5)
				Functions.MedHandler:FireServer(SavedTarget,2)
			end
		end
		TreatDebounce = true
	end
end)

script.Parent.Treat.Frame.BandFrame.Tourniquet.MouseButton1Down:Connect(function()
	if TreatDebounce and Human.Health > 0 and not Char.ACS_Client:GetAttribute("Collapsed") then
		TreatDebounce = false
		if Target.Value == nil then
			if Char.ACS_Client:GetAttribute("Bleeding") == true or Char.ACS_Client:GetAttribute("Tourniquet")then
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(1.5,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(1.5)
				Functions.MedHandler:FireServer(nil,3)
			end
		else
			if Target.Value.Character.ACS_Client:GetAttribute("Bleeding") or Target.Value.Character.ACS_Client:GetAttribute("Tourniquet") then
				SavedTarget = Target.Value
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(1.5,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(1.5)
				Functions.MedHandler:FireServer(SavedTarget,3)
			end
		end
		TreatDebounce = true
	end
end)

script.Parent.Treat.Frame.MedFrame.PainRelief.MouseButton1Down:Connect(function()
	if TreatDebounce and PainRelief.Value > 0 and Human.Health > 0 and not Char.ACS_Client:GetAttribute("Collapsed") then
		TreatDebounce = false
		if Target.Value == nil then
			if Char.ACS_Client.Variaveis.Dor.Value > 0 then
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(1.5,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(1.5)
				Functions.MedHandler:FireServer(nil,4)
			end
		else
			if Target.Value.Character.ACS_Client.Variaveis.Dor.Value > 0 then
				SavedTarget = Target.Value
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(1.5,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(1.5)
				Functions.MedHandler:FireServer(SavedTarget,4)
			end
		end
		TreatDebounce = true
	end
end)

script.Parent.Treat.Frame.MedFrame.Energy.MouseButton1Down:Connect(function()
	if TreatDebounce and EnergyShot.Value > 0 and Human.Health > 0 and not Char.ACS_Client:GetAttribute("Collapsed") then
		TreatDebounce = false
		if Target.Value == nil then
			if Char.Humanoid.Health < Char.Humanoid.MaxHealth then
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(3,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(3)
				Functions.MedHandler:FireServer(nil,5)
			end
		else
			if Target.Value.Character.Humanoid.Health < Target.Value.Character.Humanoid.MaxHealth then
				SavedTarget = Target.Value
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(3,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(3)
				Functions.MedHandler:FireServer(SavedTarget,5)
			end
		end
		TreatDebounce = true
	end
end)

script.Parent.Treat.Frame.NeedFrame.Suppressant.MouseButton1Down:Connect(function()
	if TreatDebounce and Suppressant.Value > 0 and Human.Health > 0 and not Char.ACS_Client:GetAttribute("Collapsed") then
		TreatDebounce = false
		if Target.Value == nil then
			if Char.ACS_Client.Variaveis.Dor.Value > 0 then
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(10,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(10)
				Functions.MedHandler:FireServer(nil,6)
			end
		else
			if Target.Value.Character.ACS_Client.Variaveis.Dor.Value > 0 then
				SavedTarget = Target.Value
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(10,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(10)
				Functions.MedHandler:FireServer(SavedTarget,6)
			end
		end
		TreatDebounce = true
	end
end)

script.Parent.Treat.Frame.NeedFrame.EnergyShot.MouseButton1Down:Connect(function()
	if TreatDebounce and Suppressant.Value > 0 and Human.Health > 0 and not Char.ACS_Client:GetAttribute("Collapsed") then
		TreatDebounce = false
		if Target.Value == nil then
			if Char.Humanoid.Health < Char.Humanoid.MaxHealth then
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(10,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(10)
				Functions.MedHandler:FireServer(nil,7)
			end
		else
			if Target.Value.Character.ACS_Client:GetAttribute("Collapsed") then
				SavedTarget = Target.Value
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(10,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(10)
				Functions.MedHandler:FireServer(SavedTarget,7)
			end
		end
		TreatDebounce = true
	end
end)

script.Parent.Treat.Frame.OtherFrame.Bloodbag.MouseButton1Down:Connect(function()
	if TreatDebounce and SacoDeSangue.Value > 0 and Human.Health > 0 and not Char.ACS_Client:GetAttribute("Collapsed") then
		TreatDebounce = false
		if Target.Value == nil then	
			if Char.ACS_Client.Variaveis.Sangue.Value < Char.ACS_Client.Variaveis.Sangue.MaxValue then
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(20,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(20)
				Functions.MedHandler:FireServer(nil,8)
			end
		else
			if Target.Value.Character.ACS_Client.Variaveis.Sangue.Value < Target.Value.Character.ACS_Client.Variaveis.Sangue.MaxValue then
				SavedTarget = Target.Value
				Timer.Size = UDim2.new(0,0,1,0)
				TS:Create(Timer, TweenInfo.new(20,Enum.EasingStyle.Linear), {Size =  UDim2.new(1,0,1,0)}):Play()
				wait(20)
				Functions.MedHandler:FireServer(SavedTarget,8)
			end
		end
		TreatDebounce = true
	end
end)

