if Logic==1 then if Distance>=1 then if ClimbingLadder==false then TurnRight()end else TurnLeft()end if FireRayAhead()then TurnLeft()if FireRay()then TurnLeft()if FireRay()then TurnLeft()if FireRay()then targpos=torsoPos+Vector3.new(Xdir,0,Zdir)hum.Jump=true end end end else if Xdir==OldX and OldZ==Zdir then Logic=0 end end end

	if Logic == 1 then

		if Distance >= 1 then
			if ClimbingLadder == false then -- or target.Position.y < torsoPos.y + 4 then 
				TurnRight()
			end -- else go straight or go up
		else
			TurnLeft()
		end

		if FireRayAhead() then  -- Check straight first. (And Diagonaly left)
			TurnLeft()
         if FireRay() then  -- Check left (And Diagonaly left & back)
				TurnLeft()
				if FireRay() then
					TurnLeft()
					if FireRay() then
						targpos = torsoPos + Vector3.new(Xdir,0,Zdir)
						hum.Jump = true
					end -- right
				end -- Back
			end -- Left
		else -- If succesful Ahead then... (We only check RightTurns for a get-out-of-jail-Free card)

			if Xdir == OldX and OldZ == Zdir then -- Gracefully exiting Logic 1
				Logic = 0
			end -- check Goal dir?
		end -- Ahead
	end -- Logic 1
