--Function For Making Rays Which Kills Bricks


function ray(angle,radius, orig)
	----------------SET POSITIONS
	local startPos = (orig * CFrame.new(0,0,3) ).p
	local secondPos = orig
					* CFrame.Angles(0, 0, math.rad(angle))
					* CFrame.new(radius,0,-6)

	----------------MAKE RAY
	local  damageRay = Ray.new	(startPos,(secondPos - startPos).p)
	local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(damageRay, ignoreList)
	--if hit then print("Hit: "..hit.Name) else print("Hit: nil") end
	
	----------------DRAW RAY
	if makeRays then
		local distance = (position - startPos).magnitude
		makeRay(CFrame.new(startPos, secondPos.p) * CFrame.new(0, 0, -distance/2),
		Vector3.new(0.2, 0.2, distance))
	end
	
	if not hit then return end
	if hit.Name == "FakeTrack" then
		ignoreList[#ignoreList+1] = hit
		ray(angle,radius, orig)
		return
	end
	if not hit.Parent then return end
	local human = hit.Parent:findFirstChild("Humanoid")
	local player = game.Players:findFirstChild(hit.Parent.Name)
	if human and player then
		if player.TeamColor ~= BrickColor.new("Earth green") then
			human:takeDamage(6000)
		end
	end
	
	if hit.Parent.Name == "Parts" then return end
	
	if hit.Parent.Parent then --look if what we hit is a tank
		tank = hit.Parent.Parent:findFirstChild("Tank")
	
		if not tank and hit.Parent.Parent.Parent then
			tank = hit.Parent.Parent.Parent:findFirstChild("Tank")
		end
	end
	
	if not tank or tank == parts.Parent.Parent.Tank then return end
	----------------IF ITS A DAMAGEABLE PART
	local damagable = hit.Parent:findFirstChild("Damage")
	if damagable then
		if damagable.Value == "Barrel" and not tank.Parent.GunDamaged.Value and math.random(1,8) == 1 then
			tank.Parent.GunDamaged.Value = true
			print("Damaged Barrel")
			
		elseif damagable.Value == "LTrack" and not tank.Parent.LTrack.Value and math.random(1,8) == 1 then
			tank.Parent.LTrack.Value = true
			print("Damaged Left Track")
			
			local list = hit.Parent:getChildren()
			local randSide = math.random(1,2)
			for i = 1, #list do
				if list[i].Name == ("trackDamage"..randSide) then
					list[i].Transparency = 1
				end
			end
		elseif damagable.Value == "RTrack" and not tank.Parent.RTrack.Value and math.random(1,8) == 1 then
			tank.Parent.RTrack.Value = true
			print("Damaged Right Track")
			
			local list = hit.Parent:getChildren()
			local randSide = math.random(1,2)
			for i = 1, #list do
				if list[i].Name == ("trackDamage"..randSide) then
					list[i].Transparency = 1
				end
			end
		end
		
	elseif hit.Name == "Fuel" then --if we hit their weak point
		tank.Value = BrickColor.new("Black")
	else
		local damage = hit:findFirstChild("Damage")	--Check if There's a Damage Value Already in the Brick
		if not damage then
			damage = Instance.new("NumberValue")
			damage.Parent = hit
			damage.Name = "Damage"
			local volume = hit.Size.X*hit.Size.Y*hit.Size.Z
			damage.Value = volume*hit.Parent.ArmourValue.Value
		end
		damage.Value = damage.Value - dealingDamage
		if damage.Value <= 0 then
			if math.random(1,2) == 1 then
				hit:BreakJoints()
			else
				hit:remove()
			end
		end
	end
end


round					= Instance.new("Part", user)
round.Name				= "RayPart"
round.Material          = "Neon"
round.Transparency		= 0.5
round.Anchored			= true
round.CanCollide		= false
round.TopSurface		= Enum.SurfaceType.Smooth
round.BottomSurface		= Enum.SurfaceType.Smooth
round.formFactor		= Enum.FormFactor.Custom
round.BrickColor		= BrickColor.new("New Yeller")
yOffset					= -0.2