function CreateRegion3FromLocAndSize(G,z)local q=z/2 local u=G-q local t=G+q return Region3.new(u,t)end function FindNear(G,z)local q=CreateRegion3FromLocAndSize(G.Position,Vector3.new(G.Size.X+z,50,G.Size.Z+z))return(Game:GetService("\087\111\114\107\115\112\097\099\101")):FindPartsInRegion3(q,G,100)end while true do for G,z in ipairs(Shield:GetChildren())do if z:IsA("\066\097\115\101\080\097\114\116")==true and(z.Name~="\079\118\101\114\104\101\097\100"and z:FindFirstChild("\073\103\110\111\114\101")==nil)then for G,q in ipairs(FindNear(z,15))do if q:IsA("\066\097\115\101\080\097\114\116")==true then local G,u=GetOwnerAndDamage(q)if G~=nil and(u~=nil and q:FindFirstChild("\080\105\101\114\099\101")==nil)then if(q.Position-z.Position).magnitude<=15 and q~=z then if Health>0 then if Health>=u then Health=Health-u HealthBar.Shield.Bar:TweenSize(UDim2.new(Health/MaxHealth,0,1,0),Enum.EasingDirection.In,Enum.EasingStyle.Linear,.5,true)for G,z in ipairs(q:GetChildren())do if z:IsA("\084\111\117\099\104\084\114\097\110\115\109\105\116\116\101\114")==true then z:Destroy()end end q:Destroy()if Health>0 then else HealthBar.Parent.Parent:Destroy()end else HealthBar.Parent.Parent:Destroy()end else HealthBar.Parent.Parent:Destroy()end end end end end end end;(Game:GetService("\082\117\110\083\101\114\118\105\099\101")).Stepped:wait()end
--for _, item in ipairs(Shield:GetChildren()) do
--	if item:IsA("BasePart") == true and item:FindFirstChild("Ignore") == nil then
--		item.Touched:connect(function(Hit)
--			if Hit == nil then return end
--			if Hit.Parent == nil then return end
--
--			local Item = Hit.Parent
--
--			if Item:IsA("Tool") == true then return end
--			if Hit.Name == "Torso" then return end
--			if Hit.Name == "HumanoidRootPart" then return end
--			if Hit.Name == "Left Leg" then return end
--			if Hit.Name == "Right Leg" then return end
--			if Hit.Name == "Head" then return end
--			if Hit.Name == "Left Arm" then return end
--			if Hit.Name == "Right Arm" then return end
--
--			if Game:GetService("Players"):GetPlayerFromCharacter(Item) ~= nil then return end
--
--			for _, x in ipairs(Hit:GetChildren()) do
--				if x:IsA("TouchTransmitter") == true then x:Destroy() break end
--			end
--
--			if Item.Name == "ShadowGrab" then
--				Health = Health - (MaxHealth / 12)
--
--				HealthBar.Shield.Bar:TweenSize(UDim2.new((Health / MaxHealth), 0, 1, 0), Enum.EasingDirection.In, Enum.EasingStyle.Linear, 0.5, true)
--
--				Item:Destroy()
--
--				if Health > 0 then
--					-- yay, still alive.
--				else
--					HealthBar.Parent.Parent:Destroy()
--				end
--			end
--		end)
--	end
--end

function CreateRegion3FromLocAndSize(Position, Size)
	local SizeOffset = Size / 2
	local Point1 = Position - SizeOffset
	local Point2 = Position + SizeOffset
	return Region3.new(Point1, Point2)
end

function FindNear(part, radius)
	local r = CreateRegion3FromLocAndSize(part.Position, Vector3.new(part.Size.X + radius, 50, part.Size.Z + radius))

	return Game:GetService("Workspace"):FindPartsInRegion3(r, part, 100)
end

while true do
	for _, x in ipairs(Shield:GetChildren()) do
		if x:IsA("BasePart") == true and x.Name ~= "Overhead" and x:FindFirstChild("Ignore") == nil then
			for _, item in ipairs(FindNear(x, 15)) do
				if item:IsA("BasePart") == true then
					local own, dmg = GetOwnerAndDamage(item)

					if own ~= nil and dmg ~= nil and item:FindFirstChild("Pierce") == nil then
						if (item.Position - x.Position).magnitude <= 15 and item ~= x then
							if Health > 0 then
								if Health >= dmg then
									Health = Health - dmg

									HealthBar.Shield.Bar:TweenSize(
										UDim2.new((Health / MaxHealth), 0, 1, 0),
										Enum.EasingDirection.In,
										Enum.EasingStyle.Linear,
										0.5,
										true
									)

									for _, b in ipairs(item:GetChildren()) do
										if b:IsA("TouchTransmitter") == true then
											b:Destroy()
										end
									end

									item:Destroy()

									if Health > 0 then
										-- yay, still alive.
									else
										HealthBar.Parent.Parent:Destroy()
									end
								else
									HealthBar.Parent.Parent:Destroy()
								end
							else
								HealthBar.Parent.Parent:Destroy()
							end
						end
					end
				end
			end
		end
	end

	Game:GetService("RunService").Stepped:wait()
end
