Works on planar curves but not on non-planar curves

What should i change in this script for it to work as a non-planar curve as well? TIA.

if you dont upload your files we are guessing.
a screenshot is not enough. give us geometry and .gh file.
but first try to understand why two nodes are red. what is the error message?
merry christmas!

the very first Offset component error might be caused by the distance being zero

anyways, Offset Curve is a planar (2D) operation

for non planar curves offset will give you an error, unless you specify plane input. In your case providing XY plane in the beginning should do the trick