Update:

My script works with a few little tweaks and the thought that you safe the z offset for your main tool modules in your config an if you change your tool through a script it performs the z probe of the tool and saves it internally. If i use a tool more frequently like Tool4 i can safe it in the override with M500. After a restart the main tool should be taken from the config and other tools must be changed trhough the script.

The working script looks like so:

T-1 ;deselect any tool G28 ;home all M400 ;wait for current movement to finish G1 Z65 F800 ;move bed to a save height (65 as high as the filament storage) where no tool can interfere T4 P0 ;select tool 4 without running macros (P0) G1 X295 Y72.9 F4000 ;move TCP over the probe M400 G30 K2 H-0.8 S-2 ;Probe the tool Z offset at the current XY position and change it so Z is 0 M500 T-1 P0 ;deselect tool G28 U V Z ;home U and V

The endstop switches where set as new z probes:

; Tool Probes M558 K1 P8 C"duex.e5stop" H80 F200 ; Set left z probe with an expected 80mm probing height a probing speed of 200 mm/min M558 K2 P8 C"duex.e6stop" H80 F200 ; Set right z probe with an expected 80mm probing height a probing speed of 200 mm/min

I might put an output of the probed offset in the console so people can copy it from there