--  Find Player (& who else not to find).

function findNearestTorso(pos)  --  declare pos a local vector3
	local list = game.Workspace:children()
	local torso = nil
	local dist = 1000  -- Area to search
	local temp = nil
	local human = nil
	local temp2 = nil
	for x = 1, #list do
		temp2 = list[x]
		if temp2.className == "Model" then
			temp = temp2:findFirstChild("Torso")
			if temp ~= nil then
				human = temp2:findFirstChild("Humanoid")
				if human ~= nil and (human.Health > 0) and (temp2.Name ~= AIName) then -- not named the same as us.
					if (temp.Position - pos).magnitude < dist then
						torso = temp
						dist = (temp.Position - pos).magnitude
					end  --  closer?
				end   --  human? Not us. 
			end -- Has torso?
		end   --  Model? 
	end  --  For. Loop thru parts in Workplace

	return torso
end  -- findNearest


function DrawRay(origin, point)  -- 7 studs long
	local Ray = Ray.new(origin, (point).unit * 7) --Make the ray.
	local Hit,Position = game.Workspace:FindPartOnRay(Ray,AI) --Check for collisions along the ray, ignoring any Parts of us.

if GraphicsOn then --Graphics
	local RayPart = Instance.new("Part",AI)
	if Hit then
		if Logic == 1 then
			RayPart.BrickColor = BrickColor.new("Black") --Set its color.
		else
			RayPart.BrickColor = BrickColor.new("Bright red") --Set its color.
		end
	else
		if Logic == 1 then
			RayPart.BrickColor = BrickColor.new("White") --Set its color.
		else
			RayPart.BrickColor = BrickColor.new("Olive") --Set its color.
		end
	end
	RayPart.Transparency = 0.2 --Set its transparency.
	RayPart.Anchored = true --Set whether it will fall or not.
	RayPart.CanCollide = false --Set whether people can walk though it or not.	
   RayPart.formFactor = Enum.FormFactor.Custom --Make it so it can be small.
local Distance = (Position-origin).magnitude --Find the distance between the hit and the torso.
	RayPart.Size = Vector3.new(0.4,.2,Distance) --Set its size to the distance.
	RayPart.CFrame = CFrame.new(Position, origin) * CFrame.new(0,0,-Distance/2) --Move it halfway.
	game.Debris:AddItem(RayPart,2) --Add it to the debris.
end -- Graphics

return Hit
end -- DrawRay


function FireRayToward() -- possible path, and read the Part we hit, if any.
 ClimbingLadder = false

local originPrime = origin * Vector3.new(.8,0,0) - Vector3.new(0,.4,0) -- Offset Right + OffY
local offset = origin * Vector3.new(.8,0,0) - origin * Vector3.new(-.8,0,0) -- left (I guess this is increment. I didn't WANT to do it this way)
local point = origin.lookVector * 7 -- dir
local pointPrime = point - offset + Vector3.new(0,2,0)  -- dir + OffsetLeft + OffsetY = direction of Ray

local	Hit = DrawRay(originPrime, pointPrime) -- see if we hit anything

	if Hit then
 
		if target.Parent == Hit.Parent then