Okay threw this together, it's not the best but it works.
Go easy on me I'm new to scripting and this is one of my first full scripts.