Creating Multiple Entries in new tab based on 'Quantity' input

Hello all!

Very new to this, especially to scripting.

I am simply trying to create a way to generate multiple entries on the ‘Codes’ tab based on the Quantity Purchased in the ‘Purchases’ tab.

Currently I have an automation which allows one single entry to be created in Codes based on the New Record trigger on Purchases.

I have tried to go through scripting and cannot get my head around it and would so greatly appreciate if someone would be kind enough to assist me by any chance.

Many Thanks indeed,