After testing and tweaking I finally perfected the code, or at least the first known working iteration.
I want to say a big thank you to everybody who helped here. Your help is greatly appreciated.
I have one last question. Rather than just paste this whole script to every instance everytime I need to use it,
is it possible, and how do I make it into a script that I can add to materials under script editor?
Such that I can simply just enter one line of script everytime I want to use it to an item or instance? Also if I needed to customise it, such as enter different values, for example the
item 33, item 34, digits etc for different items via such a script, how would I go about doing all these?