My 2d tractor beam is not working

So I have two scripts, one for the ship and one for the object I want to move:

using UnityEngine;
using System.Collections;

public class TractorBeamShip : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	internal string ObjName;
	
	int range = 1;
	
	GameObject target;
	
	public Color c1 = Color.cyan;
	
	public Color c2 = new Color(1, 1, 1, 0);
	
	void OnMouseDrag(){
		
		//Find the object named after the "ObjName" variable...
		target = GameObject.Find(ObjName);
		
		//Add a line renderer...
		LineRenderer line = gameObject.AddComponent<LineRenderer>();
		
		//Set it's vertex count to 2...
		line.SetVertexCount(2);
		
		//Don't use world space...
		line.useWorldSpace = false;
		
		//Give it a new Material...
		line.material = new Material(Shader.Find("Particles/Additive"));
		
		//Set the colors...
		line.SetColors(c1, c2);
		
		//Set positions to target's position.
		line.SetPosition(range , target.transform.position);
	}
	void OnMouseUp (){
		//Get this object's line renderer...
		LineRenderer line = gameObject.GetComponent<LineRenderer>();
		
		//And destroy it.
		Destroy(line);
	}
	
	// Update is called once per frame
	void Update() {
		if (Input.GetButtonDown("Jump")){
			print (ObjName);//DUH
		}
	}
}/*IT STILL DOESN'T WORK!!!!*/

and

using UnityEngine;
using System.Collections;

public class TractorBeamScript : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	public TractorBeamShip Ship;
	
	public float range;
	
	public float TractorSpeed;
	
	void OnMouseDrag(/*Empty*/) {
		
		//Get the "ObjName" variable from "Ship" & set it to this object's name...
		Ship.ObjName = name;
		
		//Do some complicated calculations & find "Ship"'s position...
		Vector2 diff = Ship.transform.position - transform.position;
		
		//normalize diff...
		diff.Normalize();
		
		//get the angle to "Ship"...
		float rot_z = Mathf.Atan2(diff.y, diff.x) * Mathf.Rad2Deg;
		
		//& finaly, Add force towards "Ship"'s position.
		rigidbody2D.AddForce(diff * 1 * TractorSpeed);
	}
	
	// Update is called once per frame
	void Update () {
	//Empty
	}
}
/*THIS WORKS FINE*/

The problem is that I cannot seem to be able to make the “beam” part of it, the tractor part works just fine.

As supernate notes, when you create a component in code, it’s easy to forget a setting. Easier to add the LineRenderer in the Editor, at least for testing. Then can test it works at all (don’t press any buttons – the stubby thing you made should follow you around.) Then can try just SetPosition(0, Vector3.zero); SetPosition(1, Vector3.forward); in the drag. It should aim due north on a click.

If it’s in localSpace, I think the end of the line should be at “target-me”, and not target, as you have it.

Then, once it works using a pre-made lineRenderer, you could switch back to code-created, if you you like.