Script for Auto-Updating UDF on Kit Lines

We have a UDF "Total Quantities" that we use for Kit items to show the total quantities of all the components. Currently, we manually sum the quantities of the component lines and enter this into the UDF "Total Quantity" on the Kit line.

I need help creating a script that auto-updates the "Total Quantity" UDF  on the  kit lines.  The goal is for this field to automatically reflect the total of the component lines' quantities at order creation and adjust if any quantities change.

Any advice on scripting this functionality?

(I need the totals as a UDF in Sage, not for a report)

Thanks