https://www.pokecommunity.com/showthread.php?p=9709061
Made this especially for you. Have fun.
If you have any further questions about scripting, feel free to contact me on Discord or here and I'll be happy to help.
Also I suggest you read the entire thing before you start messing around with your rom, and always remember to make a backup.