I think I found the solution in this thread: Best way to get the angle between two vectors? - #10 by coolalex1835
I used the code given in the thread and so far it works properly, although I might have to do more testing later on. I will also try your solution although i’m not sure how I would write the function that calls the code, i’m not used to that formatting unfortunately.
Thanks everyone for your help.