Feel free to use this in any of your projects! :D If you'd like to understand how this script works, I have an entire video explaining just that! https://youtu.be/ytBv2-FJ6xc
An older (very similar) version of this script can be found here: https://scratch.mit.edu/projects/46508200/