You don't need a script for it; you need an expression.
You can very easily link properties between layers with expressions. In this case, you would apply an Expression Effect Slider to your null layer (or just use the opacity property of an adjustment layer). Then alt-click the opacity property for one of your layers and use the pick whip to choose the slider effect or the opacity property of your controlling layer. Now, when you change the value of the one layer, the others follow. You can copy and paste the expression that resulted from your pick whip to the other layers. (You can even choose to copy the expression only and then paste that to the rest of the layers.)
thanks a lot, totally forgot about the possibility of using expressions for this!
Works perfect now using an adjustment layer,
Great! Glad it worked for you.
You don't even need the adjustment layer. Just make the opacity expressions on all the layers point to the top "pointer" layer's opacity. Change it, and the rest follow. No need for an adjustment layer.