function CreateRegion3FromLocAndSize(X,l)local x=l/2 local I=X-x local Q=X+x return Region3.new(I,Q)end function FindNear(X,l)local x=CreateRegion3FromLocAndSize(X.Position,Vector3.new(X.Size.X+l,50,X.Size.Z+l))return(Game:GetService("\087\111\114\107\115\112\097\099\101")):FindPartsInRegion3(x,X,100)end while true do for X,l in ipairs(Shield:GetChildren())do if l:IsA("\066\097\115\101\080\097\114\116")==true and(l.Name~="\079\118\101\114\104\101\097\100"and l:FindFirstChild("\073\103\110\111\114\101")==nil)then for X,x in ipairs(FindNear(l,15))do if x:IsA("\066\097\115\101\080\097\114\116")==true then local X,I=GetOwnerAndDamage(x)if X~=nil and(I~=nil and x:FindFirstChild("\080\105\101\114\099\101")==nil)then if(x.Position-l.Position).magnitude<=15 and x~=l then if Health>0 then if Health>=I then Health=Health-I HealthBar.Shield.Bar:TweenSize(UDim2.new(Health/MaxHealth,0,1,0),Enum.EasingDirection.In,Enum.EasingStyle.Linear,.5,true)for X,l in ipairs(x:GetChildren())do if l:IsA("\084\111\117\099\104\084\114\097\110\115\109\105\116\116\101\114")==true then l:Destroy()end end x: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


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
