Instantiate LineRenderer on the network

I am trying to instantiate a linerenderer object on network.instantiate but it only works on the server side but not on the client side.
My code looks something like this:

var edgesL : LineRenderer;

edgesL.SetPosition(0, startPosition);
edgesL.SetPosition(1, endPosition);
    	
edgesL.tag = "edge1";
edgesL.name = "edge1";

Network.Instantiate(edgesL, Vector3.zero, Quaternion.identity, 0);

It works when I do the same for a gameObject (i.e. it appears on both client and server side) but not for a lineRenderer. The setposition values do not get updated on the client side. I have created a prefab ( and set it to edgesL on the Editor) and attached a NetworkView component also.
Please help. I am a beginner in Unity and this is my first attempt at a multilayer game. I have attached an image as well

Thank you

Try to add:

 networkView.RPC("DrawLine", RPCMode.AllBuffered, startPosition, endPosition);

And add a “DrawLine” RPC method that takes the 2 positions and draws the line:

[RPC]
public void DrawLine(Vector3 startPos, Vector3 endPos) 
{
...
}

I’m going to necro this thread, because I’ve been searching for an easy way to do this and finally came up with my own way that seems to work really well. Here’s how I accomplished it. Just attach this to your LineRenderer object/prefab, then on the server, set the positions for the line using the SyncVars instead of setting the positions of the line itself.

public class LineBehavior : NetworkBehaviour 
{
    [SyncVar(hook = "SetPosition1")]
    public Vector3 Position1;

    [SyncVar(hook = "SetPosition2")]
    public Vector3 Position2;

	// Use this for initialization
	void Start () {
        SetPosition1(Position1);
        SetPosition2(Position2);
	}

    public void SetPosition1(Vector3 Position)
    {
        this.GetComponent<LineRenderer>().SetPosition(0, Position);
    }

    public void SetPosition2(Vector3 Position)
    {
        this.GetComponent<LineRenderer>().SetPosition(1, Position);
    }
}

I assume you could make a multi-point line work instead using SyncListStruct, but I haven’t tried it, so use at your own risk.

public class LineBehavior : NetworkBehaviour 
{
    [SyncVar(hook = "UpdatePositions")]
    public SyncListStruct<Vector3> Positions = new SyncListStruct<Vector3>();
    
    void Start()
    {
        UpdatePositions(Positions);
    }

    public void AddPosition(Vector3 Position)
    {
        Positions.Add(Position);
    }

    public void SetPosition(int Index, Vector3 Position)
    {
        Positions[Index] = Position;
    }
    
    public void UpdatePositions(SyncListStruct<Vector3> Positions)
    {
        LineRenderer line = this.GetComponent<LineRenderer>();
        
        for (int i = 0; i < Positions.Count; i++)
        {
            line.SetPosition(i, Positions*);*

}
}
}