Error Create Pipe Two Points!

Actually I am trying to place the sprinkler at end of the pipe…then I need to connect sprinkler with that pipe.

Here is my query with my script.

I can place the sprinkler at end of the pipe. Struggling to connect with that pipe.